我是第一次尝试重写 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]
关于php - .htaccess URL 用一个和两个查询字符串变量重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8198359/