.htaccess - htaccess mod 重写 - 我可以将我的 URL 转发到另一个带有哈希标签的 URL 吗?

标签 .htaccess

这里有一个关于 mod_rewrite 的小但令人困惑的 htaccess 问题。 我们需要转发: http://www.mydomain.com/ladies-boots/?shoesize=43&calfwidth=Khttp://www.mydomain.com/ladies-boots/#nogo&somevar=1&shoesize=43&calfwidth=K

我们的代码(感谢另一篇 Stackoverflow 帖子)是:

RewriteCond %{QUERY_STRING} ^shoesize=([0-9]+)\&calfwidth=([A-Z])$ 
RewriteRule ^ladies-boots/$ http://www.mydomain.com/ladies-boots/#nogo&somevar=1&shoesize=%1&calfwidth=%2? [R=301,L]

上面的方法效果很好,除了 hash # 标签被 Apache 转义,Apache 将 URL 写为 %23 而不是 #。

有什么办法可以解决这个问题吗?我确实需要哈希标签来实现某些 Javascript/非 SE 友好的功能,并且如果没有有效的哈希标签,上述 URL 将无法使用。

非常感谢!

最佳答案

The above works great, except the hash # tag is escaped by Apache, which writes the URL as with a %23 instead of the #.

如果您在方括号内使用 NE 标志,则可以使哈希标记不转义:[R=301,L,NE]

关于.htaccess - htaccess mod 重写 - 我可以将我的 URL 转发到另一个带有哈希标签的 URL 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11740047/

相关文章:

linux - 在 .htaccess 中使用空格访问环境变量

apache - 重写规则不起作用

regex - htaccess 重写规则不适用于某些页面

php - 跨域上传类

php - Apache : .htaccess ErrorDocument up one level?

php - URL 重写 : multiple addresses per article

php - 如何为不同于指定的 request_filename 编写重写条件

php - 如何让谷歌使用 htaccess 或 php 从其索引中删除不存在的页面?

php - 6 .htaccess 重写 : Remove index. html,删除 .html,强制非 www,强制尾部斜线

.htaccess - 重定向到 Https 排除子域,但无论 WWW 与否