mod-rewrite+哈希标签 [英] Mod rewrite + hash tags

查看:112
本文介绍了mod-rewrite+哈希标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与主题标签一起请问mod-rewrite工作的?也许我的code是废话,但这似乎并没有工作:

Does mod rewrite work together with hashtags? Maybe my code is crap, but this does not seem to work:

我的网站使用这个散列标签:的index.php /#P /约

My site uses this hash tag: index.php/#p/about

它工作正常使用常规的主题标签,但我希望它与mod-rewrite工作,所以我试图用

It works fine using regular hashtags but i want it to work with mod rewrite so i tried with:

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

我的JS:

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


}

$(window).hashchange();

当我尝试mod-rewrite例如放出来不工作:

The out put does not work when i try the mod rewrite for example:

site.com/about

site.com/about

任何想法?

推荐答案

主题标签只是客户端,就不会被发送到服务器,所以你不能重写这样的网址,但你可以重定向到它与研究标记:

Hashtags are only client-side, they aren't sent to the server, so you cannot rewrite to such an URL, but you can redirect to it with the R flag:

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

这篇关于mod-rewrite+哈希标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆