javascripthtmlfilepathfile-location

Relative path does not work for JavaScript, does for CSS


I'm on a LAMP stack - here is my file structure.

html
  main.php
javascript
  main.js
style
  main.css

From main php I attempt to include the JS using:

<script src="../javascript/main.js"></script>

It doesn't work (404) but this does..

<link rel = "stylesheet" type = "text/css" href = "../style/main.css" />

What could be wrong?


Solution

  • I feel very stupid. Lots of time spent and suddenly here is the answer...

    Go to /etc/apache2/conf-available/javascript-common.conf. You will find this:

    Alias /javascript /usr/share/javascript/