在htaccess中,我想重定向所有以?p = X结尾的网址转到主页。下面是一些示例,我想进入主页,但我希望只有一个声明可用于所有有效的工作:
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" "/"
答案 0 :(得分:2)
您可以使用:
RewriteEngine on
RewriteCond %{QUERY_STRING} (?:^|&)p=\d+(?:&|$) [NC]
RewriteRule ^products/?$ /? [NC,R=301,L]