I want example.com/site/about#whoami
to be redirected to example.com/site/?page=about#whoami
using mod_rewrite directives, but I have no idea on ho
NOTE: Anchor character #
may be passed, but it has no effect on the substitution URL unless the redirection is to a page where the anchor exists. Although Apache cannot do the scrolling of the window down to the anchor, the browser will do it in that case. Here is some Apache information about redirecting anchors
You may try something like this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^site/(.*)/? site?page=$1 [NC,NE,L]
Maps
http://example.com/site/anything
To
http://example.com/site/?page=anything
String site
is assumed to be fixed.
String anything
may contain an anchor #
and it will be passed in the substitution URL.