Main site: example.com
in /var/www/example.com
.
Wordpress blog: example.com/blog
in /var/www/blog
.
Can't make it work.
server {
listen 80;
server_name example.com;
root /var/www/example.com;
# Add index.php to the list if you are using PHP
index Index.html index.html index.htm index.nginx-debian.html;
location ~* \.(ico|jpg|jpeg|png|gif|swf|css|json|txt|sd|html)$ {
try_files $uri =404;
access_log off;
expires 1d;
}
location ~* \.(js)$ {
gzip_static on;
gunzip on;
try_files $uri =404;
access_log off;
expires 1d;
}
location /blog {
alias /var/www/blog/;
#try_files $uri $uri/ /index.php?q=$request_uri;
try_files $uri $uri/ @blog;
location ~ \.php$ {
fastcgi_split_path_info ^(.*\.php)(.*)$;
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
#fastcgi_index index.php;
#include the fastcgi_param setting
include fastcgi_params;
}
}
location @blog {
rewrite ^/blog(.*) /blog/index.php?q=$1;
}
}
For http://example.com/blog
got 403 Forbidden
. Looks like alias
doesn't work with try_files
.
But even http://example.com/blog/index.php
doesn't work. Got File not found.
.