[英]rewrite multiple php query with .htaccess parameters
site .com/ info rmation.php?country= usa &state= co &city= denver 网站 .com / info rmation.php?country = 美国 &state = 合作 &city = 丹佛
to 至
site .com/ info / usa / co / denver 网站 .com / info / 美国 / co / 丹佛
.htaccess 的.htaccess
RewriteEngine On
RewriteRule ^info/([^/]+)/(.*)$/(.*)$ information.php?country=$1&state=$2&city=$3 [L]
RewriteRule ^info/([^/]+)/(.*)$ information.php?country=$1&state=$2 [L]
RewriteRule ^info/([^/]+) informationl.php?country=$1 [L]
information.php information.php文件
<?php
echo $_GET["country"].'<br>';
echo $_GET["state"].'<br>';
echo $_GET["city"].'<br>';
echo $_SERVER['QUERY_STRING']'<br>';
?>
The first two query works fine but it wont catch the third one, well it does but it attach it to the 2nd query 前两个查询工作正常,但不会捕获第三个查询,虽然可以,但是将其附加到第二个查询
usa 美国
co/denver CO /丹佛
country=usa&state=co/denver 国家= USA&状态= CO /丹佛
I think im missing something, can anyone help me ? 我想我错过了什么,有人可以帮助我吗?
You have two $
's in there. 您那里有两个
$
。 This symbol means "end of the match", so you're "city" parameter is getting gobbled up by the "state" one. 这个符号的意思是“比赛结束”,因此您的“ city”参数被“ state”一个所吞噬。 Try:
尝试:
RewriteEngine On
RewriteRule ^info/([^/]+)/([^/]+)/([^/]+)$ information.php?country=$1&state=$2&city=$3 [L]
RewriteRule ^info/([^/]+)/([^/]+)$ information.php?country=$1&state=$2 [L]
RewriteRule ^info/([^/]+) informationl.php?country=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.