how to create subdomains in apache(xampp) server?

喜欢而已 提交于 2019-11-29 23:57:24

Try this :

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.

RafaSashi

In addition to atabak's answer:

Go to Apache > Conf > Extra -> "httpd-vhosts.conf" file and add:

<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/subdomain"
ServerName subdomain.localhost.com
</VirtualHost>

Go to C:\WINDOWS\system32\drivers\etc -> "hosts" file and add:

127.0.0.1 subdomain.localhost

from Setting Up Multiple Subdomains Using Xampp /

In xampp\apache\conf\extra\httpd-vhosts.conf file add these line at the bottom of the file for subdomain support :

<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/sandbox"
   ServerName sandbox.localhost.com
</VirtualHost> 

Then in C:\windows\System32\drivers\etc\hosts file add these line at the bottom of the file :

127.0.0.1    sandbox.localhost.com

After that re-start the xampp server and open a new tab, write in the address bar

sandbox.localhost.com

Then you will see the output of index.php file which was in the sandbox folder

in httpd.xampp.conf file add this line for subdomain support :

<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/subdomain"
ServerName subdomain.localhost.com
</VirtualHost>

then add : windows hosts file and entered: 127.0.0.1 subdomain.localhost

work for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!