You have 2 solutions
1. Creating a Virtual Host for each site
In my opinion, I would recommend this solution if it's a possibility.
In this step, you would need need to create a site just as you did for your previous ones. But you will need to give them a domain like www.site3.temp
even if it won't have a dns record. (notice the .tmp
TLD)
Next, for each user that will open that site, they would need to edit their hosts file and add a line which points that temp url to your IP. Like so:
xx.xx.xx.xx www.site3.tmp
- In Linux and Mac OS the hosts file is located at
/etc/hosts
- In Windows it's located in
<Windows Installation>/system32/drivers/etc/hosts
By default, <Windows Installation>
is in C:/Windows
2. Creating an Alias
If editing of the hosts
file is not a solution, then this is you only other option
This would require you to edit your default virtual host file. It's the virtual host of www.mysite1.com
, since it's the one that is opening when you go to http://xx.xx.xx.xx/mysite3
.
This is the reason I don't like this solution since it makes stuff ugly and cluttered. And I only use it as a last resort.
In the Virtual Host configuration, add the following line (Changing the paths as required of course):
Alias /mysite3 /home/mysite3/
# Notice that there isn't a trailing slash
# So this won't work: Alias /mysite3/ /home/mysite3/
Of course, if you need to add some apache configuration to the directory, the also need to be done in the same host file.
<Directory /home/site3/>
AllowOverride All # Just an example
</Directory>
3. (Bonus) Combining both solution
This is better then the second solution, but not as good as the first one
The default Virtual Host file is the first one loaded by apache. And by default, apache loads them alphabetically. So, what you can do, you can create a new virtual host file which would precede all your other virtual hosts files.
For example, 000-default
(Which is now done in the default configuration of apache2.4).
Then create all your Aliases in that Host file, and the default URL of this virtual host would go to a 403 page. So in the end, you would get this:
www.mysite1.com --> /home/mysite1
www.mysite2.com --> /home/mysite2
xx.xx.xx.xx --> 403 Error
xx.xx.xx.xx/site3 --> /home/site3
xx.xx.xx.xx/site4 --> /home/site4
This is preferred over the second solution, since that one might conflict with your other sites. For example, it might get messed up with your URL rewrites.