将nginx重写规则转换为htaccess / apache重写规则

时间:2016-04-17 18:38:02

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


我想从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;
            }
    }

谢谢! =)

1 个答案:

答案 0 :(得分:1)

这对我来说很好!在这种情况下,我不得不说我自己看起来并不是很聪明......

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