G64 wrote:After implementing your suggested configuration, if I want to load a test page from my local XAMPP install, I should then type in my browser:
http://www.mysite.com/page1.php (using the server Alias) is that right?
So then what about if I want to load the same page from the live server?
Do I type the same?
How will my browser make the difference? Or how do I specify which server I want, local test server or www live server?
Use a local domain name for local testing for example mysitelocal.com
as if you're connected to the Internet then your browser will for sure go to your hosted mysite.com because of DNS - mysite.com at your registrar will point to your mysite.com IP at your hosting service which is what you want it to do.
ServerName mysitelocal.com
or
ServerName local.mysite.com
Hosts file
127.0.0.1 mylocalsite.com
or
127.0.0.1 local.mysite.com
You could use an alias for example:
ServerName mysite.com
ServerAlias local.mysite.com
Then type in your browser with XAMPP running and connected to the Internet
http://mysite.com will go to the Internet
http://local.mysite.com would go to your local XAMPP hosted site.
In the hosts file you would use
127.0.0.1 local.mysite.com
not
127.0.0.1 mysite.com
It's a case of understanding what the ServerName is and what the DNS
system is.
If your hosting service is on the Internet then your browser will send the request for a page through your ISP's DNS servers to look for the IP related to the domain name in the request that is registered at your domain name registrar, after first not finding it in your HOSTS file - mysite.com relates to 123.123.123.123 (or whatever the IP is)
If your hosting on your Localhost then your browser will look in the HOSTS file for an IP and related domain name then looks for a server configured with a ServerName related to that domain name usually on
port 80 and request the server for the page - 127.0.0.1 local.mysite.com (or any domain name of your choosing associated with ip 127.0.0.1 which is Localhost).
Sounds complicated but once you are engrossed in it I am sure it will become much clearer.
Hope this helps a tad.
My advise now is to get into it and have a go using say local.mysite.com or mysitelocal.com as the ServerName - you could even just use
mysite without the .com as the ServerName of your local site (I have a vhost configured in my httpd-vhosts.conf file just using
mysite as the ServerName which I use for a live server in DreamWeaver.
Always backup conf files and ini files before making any changes so that if you make any typos or errors then it a simple job to revert to a known working configuration thats lets you start over again.