‘hash’ url rewrite in .htaccess

The # can be added in the substitution URL with the NE flag. Check:

So, you may try this:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}  !articles\.html      [NC]
RewriteCond %{REQUEST_URI}  ^/articles/([^/]+)/? [NC]
RewriteRule .*       /articles.html#%1           [R,NE,L]

Redirects

http://example.com/articles/parameter

To

http://example.com/articles.html#parameter

String articles is assumed to be fixed while parameter is assumed to be variable.

Leave a Comment