我在Xampp中安装了Laravel,并用url“ http://laravel.test”配置了一个虚拟主机,因此我不必写“ http://localhost/laravel5-upaetest/public/”。
问题在于,现在每当我在浏览器中写入url“ http:laravel.test”时,它将带我到htdocs文件夹的根目录;当我写入“ localhost”时,它会将我带到laravel项目文件夹。 / p>
我该如何解决?这个想法是,当编写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>
答案 0 :(得分:0)
尝试下面的代码。
<VirtualHost *:80>
ServerAdmin admin@admin.com
ServerName laravel.test
ServerAlias laravel.test
DocumentRoot c:/xampp/htdocs/laravel5-upaetest/public/
<Directory c:/xampp/htdocs/laravel5-upaetest/public/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
谢谢。
答案 1 :(得分:0)
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\xampp\htdocs"
<Directory "C:\xampp\htdocs">
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/job/public"
ServerName job.dev
<Directory "C:/xampp/htdocs/job/public">
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>