【问题标题】:Converting apache .htaccess to nginx (mod_rewrite)将 apache .htaccess 转换为 nginx (mod_rewrite)
【发布时间】:2021-11-26 00:54:40
【问题描述】:

如果我使用 mod_rewrite,有人可以帮助我了解如何使用 Nginx。过去我使用 Apache2,但为了更好的稳定性,我被推荐使用 Nginx,但我的网站使用 mod_rewrite 使页面更友好,但现在我在 Nginx 中转换时遇到了问题。以下是 .htaccess 代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?game=$1

感谢您的帮助

【问题讨论】:

  • 您尝试过在线转换器吗?喜欢winginx.com/en/htaccess?
  • 类似于try_files $uri $uri/ /index.php?game=$uri;

标签: nginx converters


【解决方案1】:

使用this converter 会产生正确的结果:

server {
    server_name example.com;
    location / {
        try_files $uri $uri/ /index.php?game=$uri$is_args$args;
    }
}

【讨论】:

  • 对不起,我的理解不够,但我会把这段文字放在哪里?
猜你喜欢
  • 2013-02-02
  • 2012-07-19
  • 2015-05-21
  • 2011-11-25
  • 2016-12-13
  • 2020-12-23
  • 2020-09-22
  • 2012-02-25
  • 1970-01-01
相关资源
最近更新 更多