Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache/2.4.6(CentOS)虚拟主机错误404,目录和文件位于根目录之外_Apache_Redirect_Virtualhost - Fatal编程技术网

Apache/2.4.6(CentOS)虚拟主机错误404,目录和文件位于根目录之外

Apache/2.4.6(CentOS)虚拟主机错误404,目录和文件位于根目录之外,apache,redirect,virtualhost,Apache,Redirect,Virtualhost,我正在尝试在Apache/2.4.6(CentOS)上设置一个虚拟主机(比如“subdomain1.domain.com”)。web服务器没有主机名,IP地址是55.55.55.55,Apache正在端口80侦听。我有一个重定向服务处于活动状态,对“subdomain1.domain.com:80”的请求被重定向到 根据httpd.conf,DocumentRoot为“/var/www/html” 该网站的公共内容位于名为“subdomain1”的目录中,我将其放在/var/www/html目录

我正在尝试在Apache/2.4.6(CentOS)上设置一个虚拟主机(比如“subdomain1.domain.com”)。web服务器没有主机名,IP地址是55.55.55.55,Apache正在端口80侦听。我有一个重定向服务处于活动状态,对“subdomain1.domain.com:80”的请求被重定向到

根据httpd.conf,DocumentRoot为“/var/www/html”

该网站的公共内容位于名为“subdomain1”的目录中,我将其放在/var/www/html目录中。网站代码使用了一些JS/CSS,这些JS/CSS应该与我稍后要创建的其他虚拟主机相同,因此我将JS/CSS放在一个目录“libraries”中,该目录位于网站文档根目录外(意思是“/var/www/html”内),我正试图通过“./libraries/”从html代码中为它们提供访问权限

虚拟主机配置文件是一个“subdomain1.conf”,位于/etc/httpd/conf.d/”目录中,文件如下:

<VirtualHost *:80>
ServerName subdomain1.domain.com
DocumentRoot /var/www/html/subdomain1
</VirtualHost>

ServerName subdomain1.domain.com
DocumentRoot/var/www/html/subdomain1
现在,通过这种配置,我可以访问Subdomain1的网站。Subdomain1的公共内容是可以访问的,但是..问题是:Apache没有找到所有的JS/CSS,它们都返回404错误。在使用web浏览器调试时,我看到Apache搜索JS/CSS库的路径是“http://55.55.55.55/libraries/“这个返回404

知道我哪里做错了吗

非常感谢!
麦克风

以下是我的一些建议

  • 正在设置服务器FQDN的FQDN

    $nano/etc/hosts

    55.55.55.55子域1.domain.com子域1

  • 设置服务器主机名

    $nano/etc/hostname

    subdomain1.domain.com

  • 在apache Web服务器上启用mod_重写

  • 在下面创建一个.htaccess文件,并将其保存到文件夹
    /var/www/html/subdomain1/

    在RewriteBase/RewriteRule^index\.php$-[L]RewriteCond%{REQUEST_FILENAME}上重写引擎-f RewriteCond%{REQUEST_FILENAME}-重写规则/index.php[L]

  • 谢谢,, 阿夫里扎尔