1

I am working on a project using ZF3 and my requirenment related to local server. Suppose user 'test' login on the system then url for that user should be http://test.10.1.1.55

I have already googled for this and found a post Create subdomains on the fly with .htaccess (PHP)

For production environment subdomain is working properly but not for development environment. My server guys said to me this is not possible for local server so my question is this posible to create subdomains on local server like as live server?

e.g. 
http://test.10.1.1.55
http://test1.10.1.1.55

Note: Local server means I am talking about a system that can be accessed from others system on browser.

Katty
  • 489
  • 6
  • 28

2 Answers2

1

If you are using apache on Linux then you would go to

cd /etc/apache2/sites-avaiable/

cp 000-default.conf subname.localhost

nano subname.localhost.conf 

Modify DocumentRoot to the root folder of your subdomain Underneath add

ServerAlias subname.localhost
ServerName subname.localhost

Then remove the entry for:

<Directory /var/www/html>
</Directory>

Save and exit Then enable your new sub

sudo a2ensite subname.localhost.conf

sudo service apache2 reload

or

sudo service apache2 restart

Re-reading your question you may be able to just use test.localhost instead of the IP.

localhost is the url for your local server by default.

  • would test.localhost be also accessible from other systems(local network) on browser? – Katty Aug 30 '18 at 04:48
  • no you would need to find your IP address, and then reference the domain one of two ways. Through a DNS entry or a hosts entry. This will vary from OS to OS. On the system you are connecting from go to: /etc/hosts for linux or mac or https://support.rackspace.com/how-to/modify-your-hosts-file/ The end goal will be to assign a random domain , DO NOT ASSIGN LOCALHOST TO ANYTHING OTHER THAN 127.0.0.1. – Tanner Black Aug 30 '18 at 04:50
0

In this case, test.10.1.155 becomes a name, rather than an actual IP address.

You could edit your /etc/hosts file, to add all these named entries, mapped to the same local IP address.

Some additional help about the Hosts file:

https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

Gabriel
  • 1,401
  • 13
  • 21