[vc_row type=”in_container” full_screen_row_position=”middle” scene_position=”center” text_color=”dark” text_align=”left” overlay_strength=”0.3″][vc_column column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” width=”1/1″ tablet_text_alignment=”default” phone_text_alignment=”default” column_border_width=”none” column_border_style=”solid”][vc_column_text]Updated November 02, 2017
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:
[sourcecode]
RewriteCond %{REQUEST_URI} /sample\.php$
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule .* https://example.com/sample/#tag [R=301,L]
[/sourcecode]
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.
[sourcecode]
RewriteCond %{REQUEST_URI} /sample\.php$
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule .* https://example.com/sample/#tag [R=301,NE,L]
[/sourcecode]
The resulting URL will be:
https://example.com/sample/#tag
That’s it, you can now use # in the destination URL
[/vc_column_text][/vc_column][/vc_row]
2 Responses
This was a life saver. Seems like order is important, so make sure NE is at the front of the list of flags
THANK YOU you saved me