【问题标题】:Convert nginx rewrite rules to htaccess/apache rewrite rules将 nginx 重写规则转换为 htaccess/apache 重写规则
【发布时间】:2016-08-09 09:38:13
【问题描述】:


我想从 nginx 迁移到 apache2。但我不知道如何将 nginx 重写规则“转换”为 apache/htaccess 重写规则。

    location / {
            try_files $uri $uri/ /index.php;
            if ($uri ~* ^/([a-z]+)$) {
                    set $page_to_view "/index.php?p=$1";
                    rewrite ^/([a-z]+)$ /index.php?p=$1 last;
            }
    }

谢谢! =)

【问题讨论】:

    标签: apache .htaccess mod-rewrite nginx url-rewriting


    【解决方案1】:

    这对我来说很好用!在这种情况下,我不得不说我自己查这些东西不是很聪明...

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
    

    【讨论】:

      猜你喜欢
      • 2014-06-30
      • 1970-01-01
      • 1970-01-01
      • 2011-04-16
      • 2021-04-04
      • 2016-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多