How to escape pound sign in Apache RewriteRule
If you’re setting up a redirect and want to redirect to a specific page and “tab” on that page, you need to make sure Apache does not escape the URL, otherwise #
will turn into %23
. You can do that by using the NE
(no escape) flag:
RewriteRule ^/(.*) http://domain.com/services/#development [R=301,NE,L]
That said, it’s probably not a good idea to use $1
anywhere in your URL, because that would allow a user to supply anything they want and Apache wouldn’t escape that either.
Featured image by Let's Go Together.