was successfully added to your cart.
htaccess

.htaccess Rewrite changes the Anchor tag or hash (#) to %23 in the destination URL

By November 5, 2013 No Comments

You may want to use a # (Anchor tag or hash) within the destination URL you are rewriting or redirecting to and find that the resulting URL contains %23tag instead of #tag. Lets take a look at an example:

[pure_message style=”modern-alert” icon=”#”]

RewriteCond %{REQUEST_URI} /sample\.php$
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule .* https://example.com/sample/#tag [R=301,L] [/pure_message]

The resulting URL in the browser will be :

https://example.com/sample/%23tag

You can simply use the NE flag (noescape). Using this flag will prevent the special characters from being converted to their hexcode equivalent.

[pure_message style=”modern-alert” icon=”#”]

RewriteCond %{REQUEST_URI} /sample\.php$
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule .* https://example.com/sample/#tag [R=301,NE,L] [/pure_message]

The resulting URL will be:

https://example.com/sample/#tag

That’s it, you can now use # in the destination URL

 

 

Revolved

Author Revolved

More posts by Revolved

Leave a Reply