【发布时间】:2018-05-10 15:51:36
【问题描述】:
我在尝试使用 Express 和 Apache 在公共子目录中提供静态文件时遇到了几个问题。 我的工作路径如下:
- 公开
- CSS
- style.css
- CSS
- app.js
应用程序。 js文件:
var express = require('express');
var app = express();
app.use('/', express.static(__dirname + '/public'));
如果样式。 css 在公用文件夹中,一切都很好。如果我将它移动到 css 目录(更改相对 html 标记),这是我得到的错误:
https://example.com/css/style.css 404 not found
这是html文件中的链接
<link rel="stylesheet" href="css/style.css" type="text/css">
这是我的 apache 服务器配置:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /*>
ProxyPass http://127.0.0.1:8080
ProxyPassReverse http://127.0.0.1:8080
</Location>
<Directory "/var/www/">
AllowOverride None
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
</IfModule>
可能是代理问题吗?
【问题讨论】:
标签: javascript html apache express