【问题标题】:.htaccess URL rewrite with one and two query string vars.htaccess URL 重写一个和两个查询字符串变量
【发布时间】:2024-05-17 03:10:01
【问题描述】:

我是第一次尝试重写 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

【问题讨论】:

    标签: php apache .htaccess url-rewriting


    【解决方案1】:

    你可以用这个:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule countryname/(.*)/? resorts.php?countryname=$1 [NC,L]
    RewriteRule destination/(.*)/itemtype/(.*)/? rss.php?destination=$1&itemtype=$2 [NC,L]
    

    【讨论】:

      最近更新 更多