Answer the question
In order to leave comments, you need to log in
Nginx - how to move the domain.com/blog/ URL to a separate directory?
Good afternoon colleagues.
I have one site, domain.com which is located at /home/domain.com/www
everything works fine.
Now it's time to create a blog for this site.
I created /home/domain.com.blog/www and now I'm trying to set up NGINX to work with this folder.
Created a rule:
location /blog {
root /home/domain.com.blog/www;
index index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
location /blog {
root /home/domain.com.blog/www;
index index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* \.(gif|jpg|jpeg|png|ico|bmp|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|mid|js|css|woff|exe|eot|svg|ttf)$ {
root /home/domain.com.blog/www;
expires 14d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
}
}
2015/08/13 15:10:59 [error] 1127#0: *53 "/home/domain.com.blog/www/blog/2015/08/05/hello-world/index.php" is not found (2: No such file or directory), client: 81.21.83.210, server: domain.com, request: "GET /blog/2015/08/05/hello-world/ HTTP/1.1", host: "domain.com"
server {
listen 443;
root /home/domain.com/www;
index index.php;
server_name domain.com;
location ~* \.(gif|jpg|jpeg|png|ico|bmp|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|mid|js|css|woff|exe|eot|svg|ttf)$ {
root /home/domain.com/www;
expires 14d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
log_not_found off;
}
location /admin {
try_files $uri $uri/ /admin/index.php?/$request_uri;
}
location / {
try_files $uri $uri/ /index.php?/$request_uri;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Answer the question
In order to leave comments, you need to log in
The only thing that confuses me in error.log is where index.php comes from at the end of the URL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question