开发者

Redirect old products product.php links to home page in .htaccess

I am using a new eCommerce platform and I am looking for a way to make all old product.php? links redirect to the new homepage

For example in Google Webmasters it is finding these 2 links:

/product.php?productid=11012&cat=445&page=1
/product.php?productid=10348&cat=0&page=1

I want to redirect any URLs that loo开发者_如何学编程k this to the home page.

Right now I have the following in the .htaccess file

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /product\.php([?#][^\ ]*)?\ HTTP/
RewriteRule ^product\.php http://www.mysite.co.uk/ [L,R=301]

However this makes the link redirect from /product.php?productid=11012&cat=445&page=1 to ?productid=11012&cat=445&page=1 instead of redirecting to the homepage.


Add ? to the target URL to drop current/existing query string:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /product\.php([?#][^\ ]*)?\ HTTP/
RewriteRule ^product\.php http://www.mysite.co.uk/? [L,R=301]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜