Rob Morris
Rob Morris

Reputation: 533

Redirect urls with parameters to homepage url

I have the following example urls that i need redirecting to www.example.co.uk

There are many more urls further to this list that all have a wordpress/ notation.

Would I have to write a conditional rewrite for each like this:

RewriteCond %{QUERY_STRING} ^feed=comments-rss2$
RewriteRule ^/wordpress/?(.*)$ http://www.example.co.uk [R=301,L]

RewriteCond %{QUERY_STRING} ^cat=518$
RewriteRule ^/wordpress/?(.*)$ http://www.example.co.uk [R=301,L] 

or is there a rule i can write that redirect all urls that have /wordpress in them to redirect to www.example.co.uk

Upvotes: 1

Views: 1412

Answers (1)

anubhava
anubhava

Reputation: 785098

I believe a single rule like would be suffice:

RewriteCond %{QUERY_STRING} (^|&)(feed|p|cat)=[^&]+ [NC]
RewriteRule ^wordpress(/.*)?$ http://www.example.co.uk/? [R=301,L,NC]

Make sure this is very first rule in your .htaccess just below RewriteEngine On line.

Upvotes: 1

Related Questions