【发布时间】:2013-10-09 13:17:55
【问题描述】:
我在下面有一个网址:
- 如果 PropertyBuyRent=rent 且所有其他变量为空,则 url 应如下所示: http://www.mysite.com/mypage.php/TimeshareForRent/All
我该如何为此编写 htaccess?
【问题讨论】:
我在下面有一个网址:
我该如何为此编写 htaccess?
【问题讨论】:
你可以使用这条规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(testing/mypage\.php)\?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [NC]
RewriteRule ^ /%1/TimeshareForRent/All? [R=301,L]
RewriteRule ^(testing/mypage.php)/TimeshareForRent/All/?$ /$1?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [L,NC,QSA]
【讨论】:
http://www.mysite.com/mypage.php?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price=?
您可以使用此行并在 php 文件中进行如下编辑
RewriteRule ^mypage.php/TimeshareForRent/All/?$ mypage.php?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [L,NC,QSA]
当你的条件匹配时,你可以告诉你的 php 文件重定向到“mypage.php/TimeshareForRent/All”,因为按照上面的规则,它会用没有变量的那个来掩盖变量的 url
【讨论】: