php-.htaccess用一个和两个查询字符串vars重写的URL
作者:互联网
我是第一次尝试重写URL,但是我有以下需要重写的URL:
http://domain.com/resorts.php?countryname=Portugal
http://domain.com/rss.php?destination=Torremolinos&itemtype=rfamily
我在.htaccess文件中写了以下内容:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /countryname/(.*)/ resorts.php?countryname=$1
RewriteRule /destination/(.*)/itemtype/(.*)/ rss.php?destination=$1&itemtype=$2
但是,当我尝试以下操作时,我一直无法找到URL.请有人指出我可能做错了什么吗?提前谢谢了.
http://domain.com/countryname/Portugal
http://domain.com/destination/Torremolinos/itemtype/rfamily
解决方法:
您可以使用此:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule countryname/(.*)/? resorts.php?countryname=$1 [NC,L]
RewriteRule destination/(.*)/itemtype/(.*)/? rss.php?destination=$1&itemtype=$2 [NC,L]
标签:apache,php,htaccess,url-rewriting 来源: https://codeday.me/bug/20191202/2085656.html