Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Mixed locations including Wordpress

$
0
0
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

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>