配置虚拟主机和本地主机重定向到 xampp 文件夹 [英] configuring virtual host and localhost redirecting to the xampp folder

查看:37
本文介绍了配置虚拟主机和本地主机重定向到 xampp 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建虚拟主机时遇到问题.我正在使用 Windows 7 x64 专业版.在文件 C:\Windows\System32\drivers\etc\hosts 我只有这一行:

I have problem with creating virtual host. I am using Windows 7 x64 Professional. In file C:\Windows\System32\drivers\etc\hosts I have only this lines:

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>

当然,在这些文件中添加这一行后,我已经重新启动了我的 Apache 服务器.不幸的是,在浏览器中输入 myhostwww.myhost 会将我重定向到 myhost/xampp.

And of course I have restared my Apache server after adding this lines in those files. Unfortunatly typing myhost or www.myhost in my browser redirect me to the myhost/xampp.

我已经搜索过,并且在 google 和 stackoverflow 上找到了如何使用 xampp 配置虚拟主机的描述,但是我怎么知道我已经完成了一切.我知道我的问题并不新鲜,但我没有找到适合我的解决方案.

I have already search and I have found on google and also on stackoverflow description how to configure virtual hosts using xampp but how can I recognize I have done everything alright. I know that my problem isn't new but I didn't found working solution for me.

我也意识到在浏览器中输入 localhost 也会重定向我 localhost/xampp.我不知道这些问题是否与我的情况有关.

I have also recognized that typing localhost in my browser redirect me alsto localhost/xampp. I don't know whether these problems are linked in my case.

推荐答案

我遇到了同样的问题.您的第一个请求是重定向到 htdocs 根目录.如果您查看 htdocs 目录中的 index.php,您会看到非常简短的代码,它将传入的请求重定向到 xampp 目录.

I had this same issue. Your first request is redirecting to the htdocs root directory. If you look at index.php in the htdocs directory, you can see very brief code that takes the incoming request and redirects it to the xampp directory.

我通过摆弄 httpd-vhosts.conf 文件修复了它.对于您的情况,请尝试进行以下修改:

I fixed it by fiddling with the httpd-vhosts.conf file. In your case, try making the following edits:

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>

这篇关于配置虚拟主机和本地主机重定向到 xampp 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆