Issues with RewriteRule on Generic Anchor Redirect


April 2019


35 time


I want to redirect any request to the root of my site to an anchor on the index. So

Gets sent to

I've written this .htaccess file (it also redirects http requests to https, that part works, but is included for completeness)

RewriteEngine On
RewriteRule ^/(.*) /#$1 [NE,R=302]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Based on the discussion in this thread: mod_rewrite with anchor link this should work, but it's not matching for some reason. I tried out the rule given in that thread using this tool: and it doesn't seem to work there either.

I've tried clearing my cache and accessing in incognito mode, to no avail. Any help?

0 answers