2012-09-10 30 views
4

我想在我的PHP代碼獲得sort_by獲得在URL字符串變量第十,但其似乎是,這是與數字返回的變量值1 0無法通過的.htaccess

RewriteRule ^abc/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ search.php?counrty=abc&state=$1&gender=$2&r_city=$3&r_mstatus=$4&r_religion=$5&r_ethnicity=$6&r_cast=$7&r_profession=$8&r_education=$9&sort_by=$10 [NC] 
+0

你是否正確地獲得其他9個參數? – baig772

+0

是的,我正在得到所有其他參數,除了第10個是sort_by。 – Farhan

回答

2

根據Apache文檔,對於$N,值N只能是0-9。所以試圖得到$10是不會工作的。您可能需要經歷兩個重寫步驟。所以,也許你使用這樣的東西:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+/[^/]+/[^/]+)/?$ search.php?country=$1&state=$2&gender=$3&r_city=$4&r_mstatus=$5&r_religion=$6&r_ethnicity=$7&r_cast=$8&r_profession=$8&profession_and_education_and_sort=$9 [NC] 

RewriteCond %{REQUEST_FILENAME} ^search\.php$ 
RewriteCond %{QUERY_STRING} ^(country=.*&state=.*&gender=.*&r_city=.*&r_mstatus=.*&r_religion=.*&r_ethnicity=.*&r_cast=.*)&profession_and_education_and_sort=([^/]+)/([^/]+)/([^/]+) 
RewriteCond ^search\.php$ search.php?%1&r_profession=%2&r_education=%3&sort_by=%4 [NC,L] 
+0

通過用國家/地區名替換abc,我得到500內部服務器錯誤錯誤。 – Farhan

+0

你能告訴我其他的東西嗎?或者我犯了什麼錯誤? – Farhan

+0

對不起,我沒有看到'abc',本身就是替代品。我已經更新了我的答案。 –