我工作的一個項目的查詢字符串的URL的.htaccess重寫規則需要幫助,我堅持這是不工作&我試過很多東西,但沒有運氣有些.htaccess
重寫規則,所以請幫助我。關於與動態子目錄
下面是我在做什麼:
當我打開:domain.com/us/search.html?keyword=xyz&location=alabama
它應該有從根目錄下讀取文件search.php
&工作是這樣的:search.php?directory=us&keyword=xyz&location=alabama
它的正確越來越子目錄,但沒有獲取關鍵字和位置數據。
這裏是我的.htaccess
代碼:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteRule ^(.*)/(.*)-ad(.*).html ad.php?countrycode=$1&title=$2&id=$3 [NC]
RewriteRule ^(.*)/$ country.php?countrycode=$1 [NC]
RewriteRule ^(.*)/(.*)-author\.html author.php?countrycode=$1&q=$2 [NC]
RewriteRule ^(.*)/(.*)-author/currentpage=(.*) author.php?countrycode=$1&q=$2¤tpage=$3 [NC]
RewriteRule ^(.*)/search\.html?keyword=(.*)&location=(.*) search.php?countrycode=$1&keyword=$2&location=$3 [NC,L]
RewriteRule ^(.*)/search\.html$ search.php?countrycode=$1 [NC,L]
RewriteRule ^(.*)/latest\.html$ latest.php?countrycode=$1 [NC,L]
RewriteRule ^(.*)/submit\.html$ submit.php [NC,L]
RewriteRule ^error\.html$ error.php [NC,L]
ErrorDocument 400 /error.html
ErrorDocument 401 /error.html
ErrorDocument 403 /error.html
ErrorDocument 404 /error.html
ErrorDocument 500 /error.html
添加了此功能並立即開始工作,感謝您的幫助。 'RewriteRule ^(。*)/ search \ .html $ search.php?countrycode = $ 1 [NC,L,QSA]' –
那麼,爲什麼你不接受正確的答案呢? – spirit
完成了,我接受了正確答案 –