Reputation: 9221
Can I RewriteRule from page index2.php?q=xxx
to index2.php#!q=xxx
?
I tired code, but still not work. So is it possible? Or I need relay on js window.location.hash
, how? Thanks.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index2.php#!q=([^/]*)$ index2.php?q=$1
</IfModule>
Upvotes: 0
Views: 341
Reputation: 33904
Try this to redirect ?q=
to #!q=
:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(q=.*)$
RewriteRule ^index2.php index2.php#!$1 [NE,L,R]
If you want to redirect from #!q=
to ?q=
, you have to use JavaScript:
if( window.location.hash.match(/^#!(q=.*)$/) )
window.location.replace( "?" + RegExp.$1 ); // redirect
Upvotes: 3