如何在 apache(xampp) 服务器中创建子域? [英] how to create subdomains in apache(xampp) server?

查看:36
本文介绍了如何在 apache(xampp) 服务器中创建子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在本地 xampp 安装中创建子域已有一段时间了.我尝试编辑我的 httpd.conf 文件并输入以下内容:

I've trying to create subdomain in my local xampp installation for some time. I tried editing my httpd.conf file and I entered the following:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /ecommerce
ServerName ecomm.localhost
</VirtualHost>

我还编辑了我的 windows 主机文件并输入:127.0.0.1 ecomm.localhost

I also edited my windows hosts file and entered: 127.0.0.1 ecomm.localhost

但是当我在我的 Firefox 中输入ecomm.localhost"时,它给了我:禁止访问!!!可以请任何人帮助我吗?我到底做错了什么?我对此很陌生.我只想在我的htdocs"文件夹中创建多个文件夹,并将它们用作具有子域的不同网站.例如:c:\xampp\htdocs\mainSite -----> mainSite.com 或 mainSite.localhostc:\xampp\htdocs\subSite -----> subSite.mainSite.com 或 subSite.mainSite.localhost

But when I type 'ecomm.localhost' in my firefox it gives me: Access forbidden!!! Can please anybody help me out? What exactly I'm doing wrong? I'm fairly new to this. I simply want to create multiple folders in my 'htdocs' folder and use them as different websites with subdomain. For example: c:\xampp\htdocs\mainSite -----> mainSite.com or mainSite.localhost c:\xampp\htdocs\subSite -----> subSite.mainSite.com or subSite.mainSite.localhost

推荐答案

试试这个:

NameVirtualHost 127.0.0.1:80
<VirtualHost *:80>
<Directory "C:\path\to\ecommerce">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
</Directory>
ServerName ecomm.localhost
ServerAlias www.ecomm.localhost
DocumentRoot "C:\path\to\ecommerce"
</VirtualHost>

是的,您正确编辑了主机文件.

Yes you edited your hosts file correctly.

这篇关于如何在 apache(xampp) 服务器中创建子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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