问题
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