配置虚拟主机和本地主机重定向到xampp文件夹
我在创建虚拟主机时遇到了问题。我正在使用Windows 7 x64 Professional。在文件C:\Windows\System32\drivers\etc\hosts
我只有这行:配置虚拟主机和本地主机重定向到xampp文件夹
127.0.0.1 myhost
127.0.0.1 www.myhost
而且在文件C:\xampp\apache\conf\extra\httpd-vhosts.conf
我有这样的:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
ServerAlias www.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/Users/Me/Dropbox/Project/public"
ServerName myhost
ServerAlias www.myhost
<Directory "C:/Users/Me/Dropbox/Project/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
当然,我已经将这些文件中这一行之后restared我的Apache服务器。 不幸打字myhost
或www.myhost
在我的浏览器上将我重定向到myhost/xampp
。
我已经搜索和我已经在谷歌发现也计算器描述了如何使用XAMPP配置虚拟主机,但我怎么能认识我所做的一切都是正常的。我知道我的问题不是新的,但我没有找到适合我的工作解决方案。
我也认识到打字localhost
在我的浏览器中重定向我alsto localhost/xampp
。我不知道这些问题是否与我的情况相关。
我有这个相同的问题。您的第一个请求将重定向到htdocs根目录。如果您查看htdocs目录中的index.php,可以看到非常简短的代码,它接收传入的请求并将其重定向到xampp目录。
我修正了httpd-vhosts.conf文件。在您的情况下,请尝试进行以下编辑:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\xampp\htdocs\
ServerName localhost
</VirtualHost>
<VirtualHost www.myhost>
DocumentRoot "C:\Users\Me\Dropbox\Project\public"
ServerName www.myhost
ServerAlias www.myhost
<Directory "C:\Users\Me\Dropbox\Project\public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
你救了我的一天,感谢完美的答案! – 2013-04-25 08:16:17
对于我目前的测试XAMPP(1.8.1)的配置文件在httpd-vhosts.conf'位于'XAMPP_INSTALLATION \ apache的\的conf \ extra' – 2016-02-09 21:11:33
但随着''/'',不''\''不管视窗。或者没有斜杠... – Qwertiy 2017-04-04 16:08:26
您需要启用基于名称的虚拟主机。
近在C文件的顶部:\ XAMPP \ apache的\的conf \额外\的httpd的虚拟主机
取消注释#NameVirtualHost *:80
即来自:
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
要:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
(注意最后一行是现在取消注释ED)。
工作就像一个魅力对我来说。 :)
我怀疑这是OP的问题,因为在他的第二个代码块中,它是第一个(未注释的)行! ;-)但是,欢迎来到SO!:-) – 2012-11-08 02:03:55
他的例子已经'NameVirtualHost'取消注释... – Blaskovicz 2012-11-08 02:04:03
我有一个类似的问题,并发现我不得不去我的Apache24主httpd.conf文件并取消围绕行501“包括conf/extra/httpd-vhost.conf” 我从来没有使用过它仍然被排除。希望这有助于任何人在这里找不到其他答案。我的Apache24现在可以看到我的虚拟主机文件。
遵循以下已工作液URL [本地主机与虚拟主机和工作(http://*.com/a/39037872/2363138) – Raj 2016-08-19 11:31:21