AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-361481

NaturalDevCR's questions

Martin Hope
NaturalDevCR
Asked: 2016-06-27 23:38:48 +0800 CST

NGINX index.php 重写规则不起作用

  • 1

最近我将我的网络服务器从 cpanel 和 CENTOS 7 更改为使用 nginx 和一个名为 nDeploy 的 scipt,它与 wordpress 和托管在我服务器上的站点配合得很好。

我有这个脚本不起作用。由于 nginx 配置,我的站点使用主 index.php 访问大多数页面,并带有一些 php 模板解决方案,但我只收到此错误:"500 too many redirects"

所以这是我的 .htaccess (当我使用 apache 时,这就是诀窍):

    Options +FollowSymLinks

RewriteEngine On 
RewriteRule ^([^/]*)\.php$ index.php?page=$1 [L,QSA]

这是我的 nginx 配置文件:

# Downloads
rewrite ^/downloads/([0-9]+)/([^/]*)$ /./downloads.php?action=displaycat&catid=$1 last;
rewrite ^/downloads$ /./downloads.php last;

#Knowledgebase
rewrite ^/knowledgebase/([0-9]+)/[a-zA-Z0-9-]+\.html$ /./knowledgebase.php?action=displayarticle&id=$1 last;
rewrite ^/knowledgebase/([0-9]+)/([^/]*)$ /./knowledgebase.php?action=displaycat&catid=$1 last;
rewrite ^/knowledgebase$ /./knowledgebase.php last;


location / {
        try_files $uri $uri/ /index.php?$args;
}

location /NaxsiRequestDenied {
       return 418;
   }

location ~ ^/pingphpfpm$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/opt/remi/php56/root/var/run/user.sock;
}

location ~* /\.(?!well-known\/) { deny all; access_log off; log_not_found off; }
autoindex on;

location ~ \.php$ {
    include /etc/nginx/conf.d/naxsi_learn.rules;
    include /etc/nginx/sites-enabled/mysite.com.nxapi.wl;

    try_files $uri =404;
        fastcgi_pass unix:/opt/remi/php56/root/var/run/extranet.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
}

include /etc/nginx/conf.d/cpanel_services.conf;
# nginx configuration
location / {
rewrite ^/([^/]*)\.php$ /index.php?page=$1 break;
}

这是我的 index.php 文件:

<?php ob_start();
include "inc/config.php";
    $page = $_GET["page"];  
    if(!isset($page) || $page == "" ){ 
        header("Location:".SITE."index.php");
        exit();
    }
    $access = 1;

include "inc/template.php";
ob_flush();
?>
php .htaccess nginx conf
  • 1 个回答
  • 1138 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve