I have two web folders:
/var/www/mainapplication.com/public
/var/www/helpsystem
they are both PHP sites. From the main application, you can click on a "help" button that links to https://mainapplication.com/help.php
Problem:
Right now, when someone clicks on the help button, the tries to download the file help.php.
Code:
/var/www/mainapplication.com/help.php looks like this in part:
$url = https://mainapplication.com/help/index.php
$header("Location:$url");
The nginx conf file looks like this:
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;
}
}
It seems the php section is not working for the help system, although it is for the main site. Any tips would be appreciated. right now I'm trying to switch between the alias command and another root command.
EDIT 1
when I change the nginx conf to look like this:
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;
}
I get the following error:
2020/03/24 19:37:06 [error] 9241#9241: *1 rewrite or internal redirection cycle while internally redirecting to "/=404", client: 198.1.2.1, server: mainapplication.com, request: "GET /help.php HTTP/1.1", host: "mainapplication.com", referrer: "https://mainapplication.com/widget_settings.php"
Expand the wiki section:
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;
}
}