首页 > apache rewrite 如何转成 nginx rewrite

apache rewrite 如何转成 nginx rewrite

I am a newbie. 想知道对于 apache rewrite,一般都如何转成 nginx 的,比如下面的 apache 规则怎么转:

 <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{REQUEST_URI} !dispatch\.php$
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule .* dispatch.php [L,QSA]
 </IfModule>

很简单。理解你的 Apache httpd 规则,然后把它的功能用 nginx 的规则写出来。和翻译差不多的事情。

你这个规则是说,如果访问的 URI 不是以 dispatch.php 结束的,并且访问的文件不存在,那么就重定向到 dispatch.php 上。nginx 里可以直接这么写:

try_files $uri /dispatch.php;

Apache Rewrite转Nginx Rewrite

【热门文章】
【热门文章】