0

i have the following nginx config:

server {

    listen          80;
    listen          [::]:80;

    listen          443;
    listen          [::]:443;

    server_name     oreqizer.com;

    location / {
           root /var/www/oreqizer/homepage/;
    }

    location /blog/ {
            alias /var/www/oreqizer/blog/public/;
    }

}

I want to have my blog (Hexo platform) available at /blog. You can check the website at http://oreqizer.com/blog . HTML is served fine from the directory I specified, but requests for .css and .js are going to /, which will be my homepage, thus having different files and assets.

How can I make asset requests from browser go to /blog ?

1 Answer 1

0

Your link leads to a 404, so no html files there. Anyway, all files should normally get served the same way. Maybe from inside your html files css and js files are called by absolute URL? If so you should change that to requests for relative URLs.
And why are you using the alias directive and not root?

3
  • try the page now. I am using alias because the ending in my config is /public/ and the route is /blog/. using root it changes requests to .../public/blog. I need the css/js files not to be requested from oreqizer.com, but from oreqizer.com/blog, because oreqizer.com is a different website
    – Idefixx
    Apr 23, 2016 at 18:00
  • Well, does it work correctly now? I see in your source code the css is requested be root-relative path (href="/blog/css/style.css"). So "blog" should be replaced with "/var/www/oreqizer/blog/public/" by nginx so that "/var/www/oreqizer/blog/public/css/style.css" is served. Right? Still I think you could let your index file request the css by href="css/style.css", which makes it relative to your html files location. Apr 23, 2016 at 20:35
  • yep, it was correct all along -__- . it was Hexo's config problem
    – Idefixx
    Apr 23, 2016 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .