简体   繁体   English

相对路径不适用于 JavaScript,适用于 CSS

[英]Relative path does not work for JavaScript, does for CSS

I'm on a LAMP stack - here is my file structure.我在 LAMP 堆栈上 - 这是我的文件结构。

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

From main php I attempt to include the JS using:从主 php 我尝试使用以下方法包含 JS:

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

It doesn't work (404) but this does..它不起作用(404),但这确实..

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

What could be wrong?可能有什么问题?

I feel very stupid.我觉得非常愚蠢。 Lots of time spent and suddenly here is the answer...花了很多时间,突然这里就是答案......

Go to /etc/apache2/conf-available/javascript-common.conf.转到 /etc/apache2/conf-available/javascript-common.conf。 You will find this:你会发现这个:

Alias /javascript /usr/share/javascript/别名 /javascript /usr/share/javascript/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM