Question

404 on javascript and css resources

  • Posted on January 9, 2015
  • richardAAsked by richardA

PROBLEM

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">

WHAT I’VE TRIED

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!

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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!

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?

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

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