Reputation: 135
In the htaccess I want to redirect all URL's that end with ?p=X to go to the home page. Here are some examples below which I want to go to the home page but I want to have just 1 statement for all that works:
Redirect 301 "/products/?p=4771" "/"
Redirect 301 "/products/?p=5226" "/"
Redirect 301 "/products/?p=4771" "/"
Redirect 301 "/products/?p=4973" "/"
Redirect 301 "/products/?p=5226" "/"
Upvotes: 1
Views: 36
Reputation: 18671
You can use:
RewriteEngine on
RewriteCond %{QUERY_STRING} (?:^|&)p=\d+(?:&|$) [NC]
RewriteRule ^products/?$ /? [NC,R=301,L]
Upvotes: 2