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 ?


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?

  • 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 '16 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. – JosefScript Apr 23 '16 at 20:35
  • yep, it was correct all along -__- . it was Hexo's config problem – Idefixx Apr 23 '16 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.