Brandrally
Brandrally

Reputation: 849

.htaccess 301 redirect inserting query string

I am trying to organise a simple 301 redirect in my .htaccess file and having some issues.

My current code looks:

RewriteRule /contact/ http://www.example.com/connect/ [R=301,L,QSA]

Though when you enter in: http://www.example.com/contact/

It redirects okay, though places in a query string: http://www.example.com.au/connect/?field=contact

Which then makes everything blow-up. I have the 301 on the top of my .htaccess file. I am not sure why this is happening.

Any suggestions would be really appreciated.

Upvotes: 2

Views: 63

Answers (2)

Tarun Mahashwari
Tarun Mahashwari

Reputation: 358

Please also try this one:

RewriteRule ^contact/$ http://www.example.com/connect/? [L,R=301]

Upvotes: 1

Amit Verma
Amit Verma

Reputation: 41219

RewriteRule ^/?contact/?$ http://www.example.com/connect/? [R=301,L,QSA]

Empty question mark at the end is important as it will discard the original query string from url. If you are u

Upvotes: 2

Related Questions