404 on javascript and css resources

January 9, 2015 3.5k views


I'm migrating from shared hosting, and trying to test my site on the new DO VPS. When I go to my new IP address, the site loads, but the following resources get a 404 error:

<link href="/javascript/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css" rel="stylesheet">
<script src="/javascript/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.js"></script>
<script src="/javascript/dialog/alert_text.js"></script>

Resources in other folders are loading fine; for example, this stylesheet loads without issue:

<link rel="stylesheet" type="text/css" href="/styles/main_style.css">


I have tried deleting my browser cache, as well as using a different browser. The files do exist on the new server in that location. I've checked that the folder is correct, and that there aren't any strange capitalization. Everything is working fine on the old server, and all I've done is copy and past to DO.

One thing to note is that I haven't pointed my DNS to DigitalOcean yet since I'm still testing. So the client browser is loading from MY.IP.ADR.ESS/javascript/... rather than MYDOMAINNAME/javascript/.... Not sure if that has something to do with it.

Thanks for the help!

  • I would look at the file systems permissions and ownerships of each path element of each problematic file being referenced, starting with the /your_web_root_here/javascript subdirectory.

  • I'm looking at the permissions now...
    The /javascript directory is owned by the exact same owner and group, and has the exact same file permissions as all other folders.

    When I point my browser to a different directory, say /css, I can see the contents of the directory. But when I point my browser to /javascript, I see 403 forbidden "You don't have permission to access /javascript/ on this server."

    I think you're right, there's a permission problem with the /javascript folder. But I'm not sure what to change since all the folders in my root dir have the same permissions.

    This should be simple... What am I missing!?

  • You probably have a misconfigured '<Directory>' directive in you webserver config file or .htaccess file (if you're using apache).

3 Answers

I found the issue, and it's a known problem: Ubuntu BUG

The problem was that the folder's name was "javascript", and the fix was simply renaming my /javascript folder to /java-script (or anything OTHER than /javascript).

Basically if you have the javascript-common package installed, it generates the following alias:

Alias /javascript /usr/share/javascript

So my WEBROOT/javascript folder was being redirected to /usr/share/javascript, giving the 403 error.

Hope this helps save someone else a few days of troubleshooting!

The issue is fairly straight-forward. On shared hosting, your resources are stored in a different path. Right now, you either don't have the files downloaded, or have them in /javascript/

Let's do this. Imagine the pathing like this:


-> javascript
--> jquery-ui-1.9.2.custom
---> css
----> smoothness
-----> jquery-ui-1.9.2.custom.css

Now, if your files are actually stored in this tree:

-> javascript
--> jquery-ui-1.9.2.custom.css

This would mean that it's looking in the wrong place for your files.

There are 2 options:

  • create the folders like you have on the shared hosting,
  • change the files so they point to the new path
  • Thanks for the quick response JonsJava. I wish that were the issue, but as I stated above, the folder structure is exactly the same on both servers.

I'm still struggling with this...

There are no .htaccess files on the server. And the server wouldn't care if there were, because Alow Override None is set.

I've changed my apache2.conf back to the default state to make sure there are no strange <Directory> directives.

I added a <Directory> for the /javascript folder and did Require all granted.

I changed permissions on the /javascript folder to chmod 777 with no effect, then changed back to chmod 755.

I'm restarting the web server after each change, but nothing has any effect. I always get a 403 forbidden error on the /javascript directory, even though the owners and permissions are the exact same as every other directory in my web root.

Is there some way to get more info on the 403 error? Some way to find out why it's not allowing access?

Have another answer? Share your knowledge.