This might seem like an odd thing to discuss, but I had a recent experience with an organisation which has their own web server [XAMPP] on a dedicated PC which they mirror up to their host. All sounds relatively straightforward you might think ?
They wanted all their users to access the internal web-server as internal.web [as a URL] and their live server as www.theirdomain.com.
Perhaps it’s blindingly obvious to a developer [like me], but this how you do it properly:
Let us say that the web-server [The XAMPP PC] has an internal IP Address of 192.168.1.100. Remember this IP. If in doubt open the console on this PC and run ipconfig.
On the web-server, you will have a file called http-vhosts.conf [probably in c:\xampp\apache\conf\extra]
Open this file in your editor [notepad is fine]
It will look something like this:
# # Use name-based virtual hosting. # ##NameVirtualHost *:80 # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ##ServerName or ##ServerAlias in any <VirtualHost> block. #
Below this you need to create an entry which looks like this :
<VirtualHost *:80> ServerAdmin yourEmail@xyz.com DocumentRoot "C:/xampp/htdocs/your-server-folder" ServerName internal.web ServerAlias internal.web </VirtualHost>
Note the coloured items are specific to your server/PC. Very unlikely that you’re not using Port 80 for the internet, but you never know. Also the folder for your web-site [local site] can be anywhere, but best practice is to have it under xampp/htdocs.
Restart your XAMPP server
On each PC [not the server] assuming it’s Windows, you have this rather hidden away file called hosts. This is in c:\windows\system32\drivers\etc
Change the permissions on this file so that you can write to it or update it. Just right-click > Security->Edit Permissions and set the file to full-access for Users.
Open the file in notepad or any editor and it will look like this:
# For example: # # 126.96.36.199 rhino.acme.com # source server # 188.8.131.52 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost
add a line at the bottom as follows:
192.168.1.100 internal.web #192.168.1.100 is the local IP of the server
Save the file and open your PC’s web browser, e.g. Chrome.
Enter the URL internal.web [no http or www etc – just this] and your local web-site on your server will open.
Why do this ?
A lot of web-sites don’t play nice unless they are resolved with a root URL and you can get HTTP 500 errors if you don’t do the above.