apache - Mod_rewrite + 主题标签

标签 apache mod-rewrite redirect

mod 重写可以与主题标签一起使用吗?也许我的代码很糟糕,但这似乎不起作用:

我的网站使用此哈希标签:index.php/#p/about

使用常规主题标签可以正常工作,但我希望它可以与 mod 重写一起使用,所以我尝试了:

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php#p/$1 [nc]

我的js:

$(window).hashchange(function(){      alert(location.hash);


}

$(window).hashchange();

例如,当我尝试 mod 重写时,输出不起作用:

site.com/about

有什么想法吗?

最佳答案

主题标签只是客户端,它们不会发送到服务器,因此您无法重写到此类 URL,但您可以使用 R 标志重定向到它:

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php#p/$1 [NC,NE,R=302]

关于apache - Mod_rewrite + 主题标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8606127/

相关文章:

php - 如何在 Laravel 中动态创建子域?

performance - EasyPHP 上的 Apache 服务器缓慢

regex - RewriteRule ^-[L]也称为RewriteRule脱字符号D

html - 从整个页面的 html 框架重定向

git - Jenkins 凭据插件和 GIT 客户端不工作

php - 如何让用户的浏览器忘记包含刷新重定向的缓存 index.html 文件?

java - JBoss AS 7 中的重写规则

Apache RewriteRule 代理不遵循重定向

php - WordPress、nginx 代理和子目录 : wp-login. php 重定向到域

c - Linux | C 中的 Shell 实现 |重定向文件包括提示