【问题标题】:Htaccess multiple parametershtaccess 多个参数
【发布时间】:2015-07-27 23:18:34
【问题描述】:

我如何才能使以下网址正常工作(将我重定向到“漂亮”网址)?

访问以下链接:

pictures.php?genre=all&sortby=popularity

访问例如(localhost/mydomain/pictures/all/popularity)的重写部分正在工作,但唯一不工作的一方是每当我访问上面的示例时,它都会将我重定向到它。

我当前的代码:

RewriteEngine on

RewriteCond %{THE_REQUEST} /pictures\.php[?\s] [NC]
RewriteRule ^pictures\.php?genre=([a-zA-Z]+)&sortby=([a-zA-Z]+)$ /mydomain/pictures/$1/$2 [NC,R=302,L,NE]

希望有帮助!

【问题讨论】:

    标签: .htaccess parameters rewriting


    【解决方案1】:

    试试这个:

    RewriteEngine On
    RewriteCond %{THE_REQUEST} /pictures\.php\?genre=([^&]+)&sortby=([^&\s]+) [NC] 
    RewriteRule ^pictures.php$ /pictures/%1/%2? [NE,NC,R,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^pictures/([^/]+)/([^/]+)/?$ /pictures.php?genre=$2&sortby=$3  [QSA,L,NC]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-06
      • 1970-01-01
      • 2019-07-03
      • 1970-01-01
      • 2013-12-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多