将.htaccess转换为nginx(mod_rewrite)

Sky*_*man 10 apache .htaccess mod-rewrite nginx

我的apache有以下.htaccess文件:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks    
# Options +SymLinksIfOwnerMatch
  RewriteEngine On
  RewriteBase /
  RewriteRule ^$          index.php       [L]
  RewriteCond %{REQUEST_FILENAME}         !-f
  RewriteCond %{REQUEST_FILENAME}         !-d
  RewriteRule (.*)        index.php?page=$1  [QSA,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

突然,我不得不将我的网络服务器更改为nginx,我不知道为什么,但mod重写不起作用.

我使用在线'转换器'来转换它,所以我有以下内容:

location / {
  rewrite ^/$ /         index.php       break;
  if ($request_filename ~         !-f){
    rewrite ^(.*)$ /       index.php?page=$1   break;
  }
}
Run Code Online (Sandbox Code Playgroud)

你能帮我解决什么问题吗?

在此先感谢Marcell

reg*_*ero 18

http://blog.martinfjordvald.com/2011/02/nginx-primer-2-from-apache-to-nginx/ 一切都在里面.不再有.htaccess,没有更复杂的规则使用try_files.

编辑:如果不明显,不要相信在线转换器.