Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache重定向301因参数而失败_Apache_.htaccess - Fatal编程技术网

Apache重定向301因参数而失败

Apache重定向301因参数而失败,apache,.htaccess,Apache,.htaccess,我尝试从此地址执行301重定向: /web/8888/nsf/sbs.py?&u ID=9884&did=3025&PF=14&G=9884&SM=9884&lang=HE&u UserReference=956357C53FD2C8024C725EE5 致此地址: /?page=product&p_id=9884 9884值是动态值,其他值始终不是 我尝试使用: Redirect 301 "/web/8888/nsf/sbs.py?&_ID=9884&did=3025&

我尝试从此地址执行301重定向:
/web/8888/nsf/sbs.py?&u ID=9884&did=3025&PF=14&G=9884&SM=9884&lang=HE&u UserReference=956357C53FD2C8024C725EE5

致此地址:
/?page=product&p_id=9884

9884值是动态值,其他值始终不是

我尝试使用:

Redirect 301 "/web/8888/nsf/sbs.py?&_ID=9884&did=3025&PF=14&G=9884&SM=9884&lang=HE&_UserReference=956357C53FD2C8024C725EE5"  /?page=product&p_id=9884
有人能帮我解决这个问题吗?

问题是在执行匹配时不检查查询字符串。相反,您需要使用来执行重定向

请记住,从您的示例URL来看,您似乎想要这样的内容:

RewriteEngine On

# Check if the path part matches the URLs we want to redirect
# If so, check if the query string contains an ID
# If we find an ID, redirect to the correct product page with that ID number
RewriteCond %{QUERY_STRING} (\A|&)_ID=([0-9]+)
RewriteRule ^web/8888/nsf/sbs\.py$ /?page=product&p_id=%2 [R=301,L]
问题是在执行匹配时不检查查询字符串。相反,您需要使用来执行重定向

请记住,从您的示例URL来看,您似乎想要这样的内容:

RewriteEngine On

# Check if the path part matches the URLs we want to redirect
# If so, check if the query string contains an ID
# If we find an ID, redirect to the correct product page with that ID number
RewriteCond %{QUERY_STRING} (\A|&)_ID=([0-9]+)
RewriteRule ^web/8888/nsf/sbs\.py$ /?page=product&p_id=%2 [R=301,L]