.htaccess - modrewrite,变量中的符号

标签 .htaccess mod-rewrite ampersand

我有一个网站,其中包含 AT&T 公园等场馆。 此页面的链接应为:/venue.php?venue=at-and-t+park

使用 htaccess,我已经将它们清理成这样了。

RewriteRule venue/([^/]+)/{0,1}$ venue.php?venue=$1 [QSA]

所以:/venue/AT-and-T+Park/

问题: 谷歌在某处查找和索引看起来像这样的链接,返回 403 错误。这是一个符号问题。

/venue/AT&T+Park/

我有没有办法改变我的重写规则来寻找这个古怪的 & 并将它转换为 -and-

最佳答案

在当前规则之前使用规则:

RewriteRule ^(.*)&(.*)$ /$1-and-$2 [L,R=301]

关于.htaccess - modrewrite,变量中的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12147814/

相关文章:

php - 使用 mod_rewrite 和 htaccess 进行 url 重定向的子域?

apache - RewriteBase 的作用是什么以及如何使用它?

elasticsearch - 如何在Elasticsearch中搜索&符?

iphone - sizeWithFont - 包含 & 字符时的奇怪行为

javascript - HTML5 History API 的 .htaccess 配置

php - 如何将整个站点从 HTTP 重定向到 HTTPS(Drupal 站点中除了 2 个页面之外)?

php - 使用自定义 htaccess mod 重写时有效路由上的 Codeigniter 404

.htaccess - 更改域名和公司名称但保持良好的 SEO

http - 使用 .htaccess 将 http 重定向到 https 时,某些网址会出现奇怪的 401 错误

svg - xlink中的&符号(&):href attributes of SVG images?