Welcome! Log In Create A New Profile

Advanced

Mixed locations including Wordpress

Posted by axeloz 
Mixed locations including Wordpress
September 16, 2014 08:31AM
Hello @all.

I have a tricky question that I cannot solve.

I have today two server configurations in Nginx: one for www.mydomain.com and one for blog.mydomain.com.
I was advised to migrate my blog under www.mydomain.com/blog for SEO purposes.

My www.mydomain.com server has many location settings:

location / {
root /var/www/site;
try_files $uri $uri/ @myframework;
}

location ~* \.php {
...
}

location @myframework {
...
}


Now I have to insert into this server my blog (Wordpress) configuration.

location /blog/ {
root /var/www/blog;
try_files $uri $uri/ @myblog;
}

location @myblog {
root /var/www/blog;
...
}

Right now, I'm able to access the blog's homepage but no skin, no JS, no image is loaded. For example:
http://www.mydomain.com/blog/wp-content/style.css
Nginx will try to get the file from /var/www/site/content/style.css instead of /var/www/blog/content/style.css
Nginx should enter the "/blog/" location and thus have the proper root directory set but it doesn't.

The problem I can imagine is that the "try_files" in the "location /" for my framework reacts first, then doesn't find the file in the site folder and therefore goes to @myframework. Proof is that the 404 error page is delivered by my framework, not by the blog nor by nginx.

So is it possible to have many try_files in the same server configuration? Have can I see the root directory?
Thanks a lot,

Axel
Re: Mixed locations including Wordpress
September 17, 2014 08:35AM
3 hours testing later, it works. Topic closed.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 104
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready