[英]Rewrite-dynamic URL .htaccess
I am trying to re-write the dynamically generated URL. 我正在尝试重新编写动态生成的URL。 But the rules i have written is not affecting the URL even a single bit. 但是我编写的规则甚至一点也不影响URL 。
The URL currently shows up like: http://ukfurniturespecialist.co.uk/county.php?c=Oxfordshire&%20t=Faringdon 该URL当前显示如下: http : //ukfurniturespecialist.co.uk/county.php?c=Oxfordshire&%20t=Faringdon
And i would like it to look like: http://ukfurniturespecialist.co.uk/county-c-Oxfordshire-t-Faringdon.html 我希望它看起来像: http : //ukfurniturespecialist.co.uk/county-c-Oxfordshire-t-Faringdon.html
This is what i have tried: 这是我尝试过的:
Options +FollowSymLinks
RewriteEngine on
RewriteRule county-c-(.*)-%20t-(.*)\.html$ county.php?c=$1&%20t=$2
Any help is much appreciated,Thanks. 谢谢您的任何帮助。
For your URL following rule should work: 对于您的网址,以下规则应适用:
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 represents a space character in url. %20代表url中的空格字符。 when writing rewrite rule the url is already decoded and handled using "\\ " instead of %20 编写重写规则时,已使用“ \\”(而非%20)对URL进行了解码和处理
For your URL the rewrite rule should be 对于您的URL,重写规则应为
Options +FollowSymLinks
RewriteEngine on
RewriteRule county-c-(.*)-\ t-(.*)\.html$ county.php?c=$1&\ t=$2
I dont think you need to put space character in your url. 我认为您不需要在网址中添加空格字符。 If you remove the %20 from your URL the rewrite rule should be 如果您从网址中删除%20,则重写规则应为
RewriteRule county-c-(.*)-t-(.*)\.html$ county.php?c=$1&t=$2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.