2010-08-23 203 views
1

我試着做301從這個地址重定向: /web/8888/nsf/sbs.py?&_ID=9884&did=3025&PF=14&G=9884&SM=9884&lang=HE&_UserReference=956357C53FD2C8024C725EE5Apache的重定向301失敗,參數

到這個地址: /?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 

有人可以幫我解決這個問題嗎?

回答

1

問題是Redirect在執行匹配時不檢查查詢字符串。相反,您需要使用mod_rewrite來執行重定向。

牢記這一點,從您的示例網址,這聽起來像你想是這樣的:

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]