Nginx fails to load JS files but loads CSS

919 Views Asked by At

I have setup a VPS with Ubuntu 14.04, Ajenti panel + Agenti V. Now I am trying to move an installation of Vanilla Forums from one server to another and it's giving me some headaches.

The forums open just fine, I can go through pages, .css files are loading but not .js files.

This is my nginx configuration in Ajenti:

try_files $uri $uri/ @rewrite;

location @rewrite {
  rewrite ^/(.*)$ /index.php?p=$1;
}

location ~ .(js|jpg|png|css)(.+)$ {
  root /srv/anunes/spacacores/;
}

The last part is my solution attempt. It does nothing.

1

There are 1 best solutions below

0
On

Ok, let me answer this question without links then :)

.(js|jpg|png|css)(.+)$

This regex says: Any character followed by one of js|jpg|png|css ending with one, or more character(s).

Lets change regex to: \.(js|jpg|png|css)(.*)$ and restart nginx and then try it again.

Why? Probably your js links has format file.js?something and css files does not, so nginx doesn't match main.css at all because it has no character(s) after css part (which is required by .+ regex's part).