【问题标题】:How to convert .htaccess RewriteRule for Nginx如何为 Nginx 转换 .htaccess RewriteRule
【发布时间】:2015-08-06 23:31:43
【问题描述】:

我正在尝试改变分页的方式,从:example.com/category?page=1example.com/category/page1/

为了这些目的,我在 .htaccess 中使用了这条规则:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((.*)/page([0-9]+)/)$ index.php?q=$2&page=$3 [L,QSA]

但是我不明白如何在nginx中做到这一点,我尝试了这个:

location / {
    if (!-e $request_filename){
        rewrite ^/((.*)/page([0-9]+)/)$ /index.php?q=$2&page=$3 break;
    }
}

它不起作用,它只会破坏一切(在类别中获得 404)

【问题讨论】:

    标签: .htaccess mod-rewrite nginx


    【解决方案1】:

    就用这个

    位置/{

    if (!-e $request_filename){
        rewrite ^/((.*)/page([0-9]+)/)$ /index.php;
    
    }
    

    }

    【讨论】:

      猜你喜欢
      • 2016-02-10
      • 2021-06-30
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 1970-01-01
      • 2018-07-10
      • 2017-08-02
      • 2011-05-07
      相关资源
      最近更新 更多