【问题标题】:htaccess rules to nginx ruleshtaccess 规则到 nginx 规则
【发布时间】:2020-10-02 18:36:50
【问题描述】:

我需要帮助将 htaccess 规则重新添加到 NGINX 规则中

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

如果这些规则可以用作 NGINX 规则,是否有人可以帮助我

【问题讨论】:

  • 在这些之后你的 .htaccess 中是否存在其他重写规则?如果请求的 PHP 脚本不存在,请求应该去哪里?对于 404 错误或像 /index.php 这样的主处理程序?
  • 不存在其他规则,只有这些规则。

标签: .htaccess nginx nginx-reverse-proxy nginx-config


【解决方案1】:

试试这个:

    location / {
        try_files $uri/ /$uri.php$is_args$args;
    }

您将需要 PHP 脚本处理程序 location 块!

    location ~ \.php$ {
        # fastcgi or other backend configuration here
        ...
    }

【讨论】:

  • @AhmedT 你的 nginx 配置中有 index 指令吗?也许你应该试试index index.php index.html index.htm;
  • 您好 Ivan,我已与脚本提供商联系,他给了我原始的 htaccess,因为他提到了 RewriteEngine On RewriteCond %{REQUEST_URI} !(/$|\.) RewriteRule ( .*) %{REQUEST_URI}/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule 。 index.php [L]
猜你喜欢
  • 1970-01-01
  • 2015-12-29
  • 1970-01-01
  • 1970-01-01
  • 2020-01-10
  • 1970-01-01
  • 2014-04-24
  • 1970-01-01
  • 2019-01-15
相关资源
最近更新 更多