P. Tran.

Ubuntu Linux Apache2 javascript folder ‘404 file not found’ error? I’ve got the fix!

I’ve had the unexpected privilege of transferring some a web application over from a CentOS Plesk/HTTPD server environment over to an Ubuntu Apache2 VPS server. The web application contained your standard CSS, images and javascript folders.

I’ve had the unexpected privilege of transferring some a web application over from a CentOS Plesk/HTTPD server environment over to an Ubuntu Apache2 VPS server. The web application contained your standard CSS, images and javascript folders.

However the most puzzling thing occurred where when I configured Apache2 to run the web application, the /javascript folder could not be read even though it was physically there and in the right place. After spending two hours attempting to remove .htaccess directives, modifying CHOWN/CHMOD permissions and double checking the Apache vhost.conf file, it came down to a .conf file configured in the default Apache2 setup that was rewriting the ‘Alias’ path of any folders beginning with /javascript.

To fix this, you will need to perform the following:

  1. Type vi /etc/apache2/conf.d/javascript-common
  2. Comment out the following line: Alias /javascript /usr/share/javascript/
  3. Save and restart Apache2 by typing /etc/init.d/apache2 restart

You may choose to rename or change the entry in point #2 above depending on whether you are sharing a javascript library across your whole Apache2 setup. Let me know if this worked for you.