Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make subdomain on my localhost? [closed]

Tags:

php

localhost

is it possible to create subdomains on my localhost? like sub.localhost and would like to know how subdomains work.

like image 759
Mehman Manafov Avatar asked Sep 13 '13 19:09

Mehman Manafov


People also ask

Can you have subdomains on localhost?

You need to set your /etc/hosts or C:\Windows\system32\drivers\etc\hosts (as administrator) to reflect the "subdomain". So add 127.0. 0.1 dev. localhost to either file (depending on your platform).

Do subdomains need their own hosting?

Because subdomains are regarded as separate websites by Google, they also need to be hosted on separate hosting plans. This means that you will need to pay a separate hosting fee for each subdomain.


1 Answers

Create a virtual host as such:

<VirtualHost *:80>     ServerName sub.localhost     DocumentRoot "C:/public_html/sub" </VirtualHost> 

And in your hosts file add this line:

127.0.0.0       sub.localhost 

Here is a useful tutorial you might find helpful.

like image 174
SeanWM Avatar answered Sep 20 '22 19:09

SeanWM