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 how to do that
Asked
Active
Viewed 1,890 times
0
ranieri
- 2,030
- 2
- 21
- 39
1 Answers
3
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.
Felipe Alameda A
- 11,791
- 3
- 29
- 37
-
Oh thanks, I got it. I've tested and it still scrolls down the page to the anchor :D – ranieri Feb 22 '13 at 22:15