Reputation: 253869
Using .htaccess, I have tried some things to redirect Urls with variables to main the domain www.my_domain.tld
, but I didn't find the right way.
I have 2 kinds of Urls that I want to redirect to my main domain:
http://www.my_domain.tld/blog/?p=125
("125" could be any number from 1 to 999)http://www.my_domain.tld/blog/feed/?p=72
("72" could be any number from 1 to 999)What I am doing wrong?
Upvotes: -1
Views: 162
Reputation: 41219
You can use the following rule in /.htaccess :
RewriteEngine on
RewriteCond %{THE_REQUEST} /blog/\?p=([0-9]+) [OR]
RewriteCond %{THE_REQUEST} /blog/feed/\?p=([0-9]+) [NC]
RewriteRule ^ http://domain.tld? [L,R,NC]
Empty question mark at the end of the destination url is important as it discards the old query strings.
Upvotes: 4