How do you rewrite a url with a # in? e.g. http://www.example.com/index.php#test
In my current .htaccess file I have:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^([^/.]+)/?$ $1.php [L] # rewrite without query string parameters
RewriteRule ^([^/.]+)/([^/.]+)/?$ $1.php\#$2 [L] # one name string parameter
This would rewrite a url such as http://www.example.com/index/test so you are directed to the page, but not take you to the relevant tag like http://www.example.com/index#test or http://www.example.com/index.php#test would.
I use something like this to redirect an url to another with a hash at the end:
Note: The # (and anything after it) is not part of the actual HTTP request to the server.
So you can’t refer to it or get the hash value in you .htaccess.
You have to use e.g. Javascript to acces values after the hash!