我已经在我的macOS上的localhost上为单独的项目设置了虚拟主机。这是httpd-vhosts.conf文件:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "/Users/Sammy/Sites"
ServerName 127.0.0.1
ServerAlias localhost
ErrorLog "/private/var/log/apache2/localhost-error_log"
CustomLog "/private/var/log/apache2/localhost-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Sammy/Sites/workspace/abc/public_html"
ServerName abc
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Sammy/Sites/workspace/xyz/public_html"
ServerName xyz
</VirtualHost>
我还更新了主机列表。问题是,当我使用此链接访问我的网站时,网站无法加载css / js文件&amp;图像出现在'public_html'目录之外,如果我通过localhost路径打开它,它就可以工作..
我来自ubuntu环境,apache目录结构在mac上相当老!任何人都可以帮助我...
由于
答案 0 :(得分:0)
网站无法加载css / js文件&amp;图像出现在&#39; public_html&#39;之外目录
这是重点。
DocumentRoot是网站的根。 下的所有内容都是网站的一部分。
通过在DocumentRoot中添加一些内容,您可以为其提供一个URL,并使其可通过HTTP进行请求。
HTTP服务器并非旨在将整个硬盘上的每个私有文件公开给全世界。那太糟糕了。
如果要为文件指定URL,请将其放在DocumentRoot中(或查看the Alias directives)。