The #
can be added in the substitution URL with the NE flag. Check:
-
This Apache link that describes specifically how to
redirect anchors
. -
Another answer in SO (mine).
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.