繁体   English   中英

重写动态URL .htaccess

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM