我正在清理一些旧东西,我需要做一些 301 重定向。
例如:
我有以下绝对 URL:http://mysite.dk/product.asp?product=371&sub=0&page=1
我需要重定向到: http://mysite.dk/category/test
我试过 htaccess:
RedirectMatch 301 /product.asp?product=371&sub=0&page=1 /category/test
但上面的代码不起作用,它显示 404 页面并忽略我刚刚进行的重定向。请注意,product.asp 不作为文件存在!
但是如果我使用:
RedirectMatch 301 /product.asp /category/test/
它工作正常,但现在我无法根据特定文件的查询字符串进行重定向。
有什么建议吗?顺便说一句,我正在使用 Prestashop=) 最好的,西蒙
最佳答案
您不能使用 RedirectMatch
指令匹配查询字符串。使用 mod_rewrite
规则代替:
RewriteEngine On
RewriteCond %{QUERY_STRING} product=371&sub=0&page=1
RewriteRule ^product\.asp$ /category/test/? [L,NC,R=301]
目标中的 ?
是剥离现有的查询字符串。
关于.htaccess - Seo 301 绝对 URL 重定向,Prestashop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33151571/