【发布时间】:2013-10-09 18:13:17
【问题描述】:
我有以下网址:
http://site/testing/mypage.php?PropertyBuyRent=sell&Developer=&Resort=&City=&State=&Country=US&Price=
我有 htaccess 来检查变量 country 中是否有内容,它会像这样更改 url:
http://site/testing/mypage.php/TimeshareForSale/US
我的 htaccess 文件如下:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(testing/mypage\.php)\?PropertyBuyRent=sell&Developer=&Resort=&City=&State=&Country=([^&]+)&Price= [NC]
RewriteRule ^ /%1/TimeshareForSale/%2? [R=301,L,NE]
RewriteRule ^(testing/mypage.php)/TimeshareForSale/([^/]+)/?$ /$1?PropertyBuyRent=sell&Developer=&Resort=&City=&State=&Country=$2&Price= [L,NC,QSA]
它工作得非常好..并将我重定向到我所说的上述网址,但在我的 php 文件中,我的变量不再有效,即 $_GET['Country'] 如果我删除 htaccess 它打印它很好。
【问题讨论】:
-
这是您在 4 小时内提出的关于 URL 重写的第三个问题——您先去阅读有关此事的教程如何?
-
if i remove the htaccess it prints it fine是什么意思? -
如果它不重写url,它会打印变量fine
-
我刚刚运行了你的代码并得到了这个查询字符串
PropertyBuyRent=sell&Developer=&Resort=&City=&State=&Country=US&Price=你可以看到$_GET['Country']在那里所以它可能是由于你的.htaccess 中的一些其他规则
标签: php apache .htaccess url mod-rewrite