【发布时间】:2018-07-05 03:10:16
【问题描述】:
我在 Xampp 中安装了 Laravel,并且我使用 URL“http://laravel.test”配置了一个虚拟主机,所以我不必写“http://localhost/laravel5-upaetest/public/”。
问题是,现在每当我在浏览器中写入 url “http:laravel.test”时,它会将我带到 htdocs 文件夹的根目录,而当我写入“localhost”时,它会将我带到我的 laravel 项目文件夹。
我该如何解决?这个想法是,当编写 laravel.test 时,它会将我带到我在 laravel5-upaetest/public 中的项目。
这是我的 httpd-vhosts.conf 文件:
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>
##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host2.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>
<Directory c:/xampp>
AllowOverride All
Require all granted
Allow from all
</Directory>
<VirtualHost *:80>
DocumentRoot c:/xampp/htdocs/laravel5-upaetest/public
ServerName laravel.test
</VirtualHost>
【问题讨论】:
-
你记得重启 apache 吗?任何配置更改(*.conf 像 vhosts 文件)都需要重新启动服务器才能加载它们。您还可以添加
AccessLog和ErrorLog指令以查看发生了什么(请参阅注释掉的##行示例)