I am using wordpress and it's a multi-site subfolder config.
- www.xyz.com is pointing to /var/www/project (Working)
- (Wordpress blog) www.xyz.com/blog is pointing to /var/www/blog (Working)
- (Wordpress blog) www.xyz.com/blog/page/2 (not working - Error given below)
So if I open page www.xyz.com/blog/page/2 or www.xyz.com/blog/2015/11/15/takeup, it should point to /var/www/blog rather than pointing to /var/www/blog/page/2/index.php.
Here is my Nginx config file:
server {
listen 80;
server_name xyz.com;
rewrite ^/(.*)/$ /$1 permanent;
return 301 $scheme://www.xyz.com$request_uri;
}
server {
listen 80 default_server;
server_name www.xyz.com;
index index.php index.html index.htm;
location / {
root /var/www/project/public;
try_files $uri $uri/ /index.php?$query_string;
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
location ~* \.(pdf)$ {
expires 30d;
}
location ~ \.(?:css|htc|js|js2|js3|js4)$ {
gzip_vary on;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location /blog {
alias /var/www/blog;
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
location ~ \.php$ {
#try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
}
}
I am getting 404:
2016/01/23 23:27:05 [error] 32532#0: *2 "/var/www/blog/page/2/index.php" is not found (2: No such file or directory), client: 27.5.217.2, server: www.xyz.com, request: "GET /blog/page/2/ HTTP/1$
(Edited to improve error log formatting)