My aim is to be able to create 2 virtual hosts where one corresponds to the dev environment and another to the test environment in my local ubuntu 16.04 machine. One thing that is particular to this application is that it has to support dynamic subdomains. Some of them are fixed like login and admin subdomain, but also each user will have their own subdomain. This virtual host works fine for the dev environment:
<VirtualHost *:80>
ServerName myapp.local
ServerAlias *.myapp.local
DocumentRoot /var/www/myapp/web
<Directory /var/www/myapp/web/>
AllowOverride All
Require local
</Directory>
ErrorLog /var/www/myapp/logs/error.log
CustomLog /var/www/myapp/logs/access.log combined
</VirtualHost>
Now I want to be able to have a virtual host for the test version and access it by this url: login.test.myapp.local, admin.test.myapp.local, ... Here is the virtual host that I have that is still not working because the request always falls in the first virtual host at this time:
<VirtualHost *:80>
ServerName test.myapp.local
ServerAlias *.test.myapp.local
DocumentRoot /var/www/test.myapp/web
<Directory /var/www/test.myapp/web/>
AllowOverride All
Require local
</Directory>
ErrorLog /var/www/test.myapp/logs/error.log
CustomLog /var/www/test.myapp/logs/access.log combined
</VirtualHost>
I know that I need to tell the first virtual host to ignore urls that start with "test." and "*.test." but I do not know how to do that.
Thanks
Because im getting an error like IP address could not be found.
I have set my DocumentRoot directory to /var/www/html/my-project/public/, is it right or need to do some other changes for root.
– Gomzy Sep 16 '19 at 06:54/etc/hosts
if there is not registered domain that points to your server. See the link at the bottom of the updated answer. – pa4080 Sep 16 '19 at 07:17/etc/hosts
? – Gomzy Sep 16 '19 at 09:14gomzy.blogspot.com
. it is possible to do without adds in the hosts file? – Gomzy Sep 16 '19 at 09:47