Mod rewrite + hash tags

笑着哭i 提交于 2019-12-30 07:11:11

问题


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

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

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]

My js:

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


}

$(window).hashchange();

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

site.com/about

Any ideas?


回答1:


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]


来源:https://stackoverflow.com/questions/8606127/mod-rewrite-hash-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!