I have the following nginx configuration to serve blog on /blog/
URL.
server {
listen 80;
server_name example.in www.example.in;
root /var/www/website;
index index.html index.htm index.php;
# Serve blog
location /blog {
return 301 /blog/;
}
location /blog/ {
autoindex on;
alias /var/www/blog/;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php$args;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}
# Serve other files
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
The homepage is working fine at https://example.in/blog
and also the admin panel is working perfectly https://example.in/blog/wp-admin/
When the blog posts permalink is set to plain, the blogs posts are opening fine with the URL
https://example.in/blog/?p=123
But on changing the permalink to another format blog/blog/2021/04/16/sample-post/
, It is giving 404
https://example.in/blog/blog/2021/04/16/sample-post/