Scott Joudry
Scott Joudry

Reputation: 902

Fragment in redirect with Apache

I have a few redirect rules that are not working as expected due to the fragment. Here is an example of the rules I am trying to get to work:

RewriteCond %{HTTP_HOST} www\.domain\.com
RewriteRule ^(.{2,5}/)?search/2016 /search?date=2016#grid [R=301,NC,L]

However, this redirects me to:

www.domain.com/search>date=2016%23grid

How do I set up my rewrite rules so the redirect is:

www.domain.com/search>date=2016#grid

Upvotes: 1

Views: 229

Answers (1)

anubhava
anubhava

Reputation: 786359

You need to use NE (No Escape) flag:

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.{2,5}/)?search/2016 /search?date=2016#grid [R=301,NC,L,NE]

Upvotes: 1

Related Questions