我有两个web文件夹:
/var/www/mainapplication.com/public
/var/www/helpsystem
它们都是PHP网站。在主应用程序中,您可以单击"帮助"按钮,该按钮链接到https://mainapplication.com/help.php
问题:
现在,当有人点击帮助按钮时,会尝试下载文件help.php。
代码:
/var/www/mainapplication.com/help.php的部分内容如下:
$url = https://mainapplication.com/help/index.php
$header("Location:$url");
nginx conf文件如下:
server {
listen 443 ssl;
root /var/www/mainapplication.com/public;
server_name mainapplication.com;
ssl_certificate /etc/ssl/a/bundle.crt;
ssl_certificate_key /etc/ssl/a/a.key;
ssl_protocols TLSv1.2;
error_log /var/log/nginx/mainapplication_com.log warn;
index login.php;
location / {
allow all;
try_files $uri $uri/ /=404;
}
location ^~ /help {
alias /var/www/helpsystem;
try_files $uri $uri/ /=404;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
php部分似乎不适用于帮助系统,尽管它适用于主站点。任何提示都将不胜感激。现在我正在尝试在alias命令和另一个root命令之间切换。
编辑1
当我把nginx-conf改成这样时:
location ^~ /help {
alias /var/www/helpsystem;
try_files $uri $uri/ /=404;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
我得到以下错误:
2020/03/24 19:37:06[error]9241#9241:*1重写或内部内部重定向到"/=404"时的重定向周期,客户端:198.1.2.1,服务器:mainapplication.com,请求:"GET/help.php HTTP/1.1",主机:"mainapplication.com",引用人:"https://mainapplication.com/widget_settings.php">
展开wiki部分:
location ^~ /wiki {
alias /var/www/helpsystem;
try_files $uri $uri/ /=404;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
location ^~ /help {
alias /var/www/helpsystem;
try_files $uri $uri/ /=404;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}