将 .htaccess 转换为 nginx (mod_rewrite) [英] Converting .htaccess to nginx (mod_rewrite)

查看:47
本文介绍了将 .htaccess 转换为 nginx (mod_rewrite)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 apache 有以下 .htaccess 文件:

I've got the following .htaccess file for my apache:

<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>

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

Suddenly I had to change my webserver to nginx and I don't know why, but the mod rewrite is not working.

我使用在线转换器"来转换它,所以我得到了以下内容:

I used an online 'converter' to convert it, so I've got the following:

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

你能帮我看看有什么问题吗?

Could you help me what's wrong?

提前致谢,马塞尔

推荐答案

http://web.archive.org/web/20180812021847/https://blog.martinfjordvald.com/2011/02/nginx-primer-2-from-apache-to-nginx/

一切都在里面.不再需要 .htaccess,不再需要使用 try_files 的复杂规则.

Everything is inside. No more .htaccess, no more complex rules use try_files.

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

EDIT: And if it is not obvious, do not trust online converters.

这篇关于将 .htaccess 转换为 nginx (mod_rewrite)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆