[英]Rewrite-dynamic URL .htaccess
我正在嘗試重新編寫動態生成的URL。 但是我編寫的規則甚至一點也不影響URL 。
該URL當前顯示如下: http : //ukfurniturespecialist.co.uk/county.php?c=Oxfordshire&%20t=Faringdon
我希望它看起來像: http : //ukfurniturespecialist.co.uk/county-c-Oxfordshire-t-Faringdon.html
這是我嘗試過的:
Options +FollowSymLinks
RewriteEngine on
RewriteRule county-c-(.*)-%20t-(.*)\.html$ county.php?c=$1&%20t=$2
謝謝您的任何幫助。
對於您的網址,以下規則應適用:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+county\.php\?c=([^&]*)&.*?t=([^&\s]*) [NC]
RewriteRule ^ county-c-%1-t-%2.html? [R=302,L]
RewriteRule ^county-c-([^-]+)-t-([^.]+)\.html$ county.php?c=$1&\%20t=$2 [L,QSA,NE]
%20代表url中的空格字符。 編寫重寫規則時,已使用“ \\”(而非%20)對URL進行了解碼和處理
對於您的URL,重寫規則應為
Options +FollowSymLinks
RewriteEngine on
RewriteRule county-c-(.*)-\ t-(.*)\.html$ county.php?c=$1&\ t=$2
我認為您不需要在網址中添加空格字符。 如果您從網址中刪除%20,則重寫規則應為
RewriteRule county-c-(.*)-t-(.*)\.html$ county.php?c=$1&t=$2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.