Javascript not working – NetworkError: 404 Not Found

Yesterday, I have deployed an application on Ubuntu server but the javascript was no longer working after configuring the virtual host.

I have taken following steps to find the problem:

  • Viewed the HTML source code using firebug and found page not found error
  • Checked the .htaccess file, but there were no problem
  • Tried a test javascript file from a different directory and it worked
  • At last, I have checked the Apache error log and found that it was attempting to load file from /usr/share/javascript/{file name}

It was very surprising because none of my site contents on that directory – /usr/share/ and didn’t do anything which may take this type of effect.

After a lot checking in the Apache configuration I found a symbolic link in the /etc/apache2/conf.d/javascript-common.conf which was causing the problem.

Alias /javascript /usr/share/javascript/

<directory "/usr/share/javascript/">
Options FollowSymLinks MultiViews
</directory>

To fix – Commented out the Alias line(1) and then restarted Apache. Everything started working fine for me.

2 Comments

Leave a Comment