Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redirect
I'm net to XAMPP. I've just installed XAMPP and configured the C:\Windows\System32\drivers\etc\hosts file with
127.0.0.1 http://www.example.com # for browser access
but with internet explorer http://www.example.com/ just displays the "Example Domain" display.
Can anyone advise how I can correct this?
Thanks
John
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
example.com is just that an example
Usually with xamp you get to your test site using http://localhost/
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
Correct syntax for a host file would be:
Code:
127.0.0.1 domain.local www.domain.local
The hosts file maps IP Address(es) to domain names... So skip the scheme, colon, and two slashes (http:// or https://). May need to reboot your computer afterwards for the changes to take effect.
I would recommend NOT mapping real domain names to the loopback IP. Better to avoid any confusion by using a completely fake domain name (also makes DNS resolution on the local computer simpler).
If you plan to set up multiple local development sites, don't forget to set up VirtualHosts (and separate document roots) for each development site in Apache.
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
Thanks korba and lhungil for your advice - actually, I'm following the Zen Cart book by Goh Koon Hoek. My hosts file is now configured as follows, but still www.example.com/ does not work. [localhost has always redirected to http://localhost/xampp/ and works file, displaying the XAMPP for Windows screen] If possible, I would like follows the examples shown in this book.
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
16:39 16/05/2015# ::1 localhost
#
#127.0.0.1 http://www.example.com # for browser access
127.0.0.1 www.example.com # for browser access
127.0.0.1 mail.example.com # for mail access
127.0.0.1 example.com # for mercury mail server
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
Quote:
I would like follows the examples shown in this book.
I remember that phase many moons ago. example.com will work but change to something yours asap, like www.mysite.local.
Quote:
16:39 16/05/2015# ::1 localhost
#
#127.0.0.1 http://www.example.com # for browser access
127.0.0.1 www.example.com # for browser access
127.0.0.1 mail.example.com # for mail access
127.0.0.1 example.com # for mercury mail server
Get rid of the debris in red, whatever that is.
When I tried this, www.example.com arrived at the Xampp front page, as it should. No restart necessary (Win7).
If yours doesn't...I don't know. You are editing the file as administrator?
Now you have to configure the Xampp apache server so it knows what to do when presented with www.example.com: which files to serve up for that domain, using a virtualhost.
While I am the first to tell people to google it, I do remember some pain in getting this to work...
You can use an alias or virtualhost. I found an alias worked up until I started to use URI remapping then had to man up to get a virtualhost working so better to do it now.
Make sure you restart apache after every change so you know when you have broken something.
Enable SSL:
Code:
C:\xampp5680-portable\apache\conf\httpd.conf
LoadModule ssl_module modules/mod_ssl.so
And this is my C:\xampp5680-portable\apache\conf\extra\httpd-vhosts.conf
with some names changed to protect the innocent.
Code:
##for all non-matching
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/xampp5680-portable/htdocs"
ServerName localhost
</VirtualHost>
## for all non-matching: SSL
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/xampp5680-portable/htdocs"
ServerName localhost
SSLEngine on
SSLCertificateFile conf/ssl.crt/server.crt
SSLCertificateKeyFile conf/ssl.key/server.key
</VirtualHost>
<VirtualHost *:80>
ServerName www.mysite.local
ServerAlias www.mysite.local
DocumentRoot "D:/My Documents/Business/Mysite/spanish website/home/public_html"
ErrorLog "logs/vhost-error.log"
CustomLog "logs/vhost-access.log" combined
<Directory "D:/My Documents/Business/Mysite/spanish website/home/public_html">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName www.mysite.local
ServerAlias www.mysite.local
SSLEngine on
SSLCertificateFile conf/ssl.crt/server.crt
SSLCertificateKeyFile conf/ssl.key/server.key
DocumentRoot "D:/My Documents/Business/Mysite/spanish website/home/public_html"
ErrorLog "logs/vhost-error.log"
CustomLog "logs/vhost-access.log" combined
<Directory "D:/My Documents/Business/Mysite/spanish website/home/public_html">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I've probably forgotten something.
As for the mail servers etc. forget them for the moment. Once you have smtp settings in the shop admin you can use real addresses and the emails will work.
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
And never will as it is an EXAMPLE
xamp does not use or require or use a domain name
If localhost then you must have zencart in another directory so
http://localhost/"your_ZenCart_directory_name"
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
FWIW, I don't even mess with the hosts file when configuring XAMPP local testbeds. I just create a /includes/local/configure.php file that contains the XAMPP based configuration (and the corresponding /admin/includes/local/configure.php). Those files "override" your webhosted settings.
I then access the "website" as localhost/zen_cart_directory_name.
Cindy
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
Quote:
I then access the "website" as localhost/zen_cart_directory_name
So you have a virtualhost per dev site to "catch" that url/address?
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
Quote:
Originally Posted by
torvista
So you have a virtualhost per dev site to "catch" that url/address?
Nope, my XAMPP installation is pretty minimal. Each site (as customized via the /local/configure.php files) is simply accessed as http://localhost/folder_name, with the Zen Cart installation files being present in c:/xampp/htdocs/folder_name.
Re: Windoews 8 XAMPP setup ...\etc\hosts config ok but www.example.com doesn't redire
Quote:
with the Zen Cart installation files being present in c:/xampp/htdocs/folder_name.
Gosh, I have been so long using alias' and virtual hosts that I never considered that!
I decided at the onset I didn't like that setup. I have six sites and wanted each website in the same directory as everything else related to that activity/business in D:My Documents etc. for various reasons:
a) keeping my data out of the C drive/all in one logical place for backups.
b) synchronisation purposes: I sync to five pcs and may have to use any one of them. While each has a Xampp installation, having the website files separate means I can use any pc for development. Using the same virtual host definition on each makes this easy.
c) I always use the latest Xampp but keep older ones, so can have multiple Xampps with the one set of website files.