【发布时间】:2012-05-25 16:29:39
【问题描述】:
首先,对不起我的英语不好。
我尝试重写从 Form Get 生成的 url 并重定向它。
我的网址是这样的:
http://www.mysite.com/properties?action=search&agreement=for-rent&category=my-category&type=&zone=my-zone&city=my-city
我已经配置了这个 .htaccess:
11. RewriteCond %{QUERY_STRING} ^action=(?:[a-zA-Z\-]*)&(?:.*)=([a-zA-Z\-]*)&(?:.*)=([a-zA-Z\-]*)&(?:.*)=([a-zA-Z\-]*)&(?:.*)=([a-zA-Z\-]*)&(?:.*)=([a-zA-Z\-]*)$
12. RewriteRule (.*) %{REQUEST_URI}/%1/%2/%3/%4/%5/? [R=301,L]
所以基本上我所有的请求都是直接到 index.php 的。
21. RewriteCond %{REQUEST_URI} !index\.php|resources|hidden
22. RewriteRule ^(.*)$ index.php/$1 [L]
一切正常,但问题是当我在查询字符串中有一个空值时,规则添加双斜杠和上面的 url(例如 whit &type=&zone=my-zone... type 有空值)将翻译像这样:
http://www.mysite.com/for-rent/my-category//my-zone/my-city/
问题是:如果查询字符串中有一个或多个空值,如何在 .htaccess 中删除生成的双斜杠?
谢谢
【问题讨论】: