Apache重定向301因参数而失败
我尝试从此地址执行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&
/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]