Reputation: 373
I have a domain that was previously owned before which was advertising products. I would like to 301 redirect all these back to the homepage if possible using .htaccess file.
Each product was built on this type of url:
/product.php?p=128842744
There's 100's of these query strings showing up so simply listing these 301 redirects would take a while.. like so
Redirect 301 /product.php?p=128842744 http://example.com
isn't there some sort of rewrite/redirect combination rule for me to do this to cover all query strings for product.php?
Only the part after "p=" changes for each url/string.
My website doesn't use query strings. I know basic knowledge of .htaccess file usage but it's a little confusing when coming to rewrite modules etc.
Any help to solve this would be great. Thanks
Upvotes: 0
Views: 4447
Reputation: 785246
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{QUERY_STRING} ^p=(.+)$ [NC]
RewriteRule ^product.php$ /? [L,R=301,NC]
Upvotes: 2