Forums / Installing on a Windows Server / Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

Views: 5,717

Results 1 to 14 of 14
16 May 2015, 4:31 PM
#1
shopserver avatar

shopserver

New Zenner

Join Date:
Jan 2007
Posts:
23
Plugin Contributions:
0

Windoews 8 XAMPP setup ...etchosts 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

17 May 2015, 1:59 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

example.com is just that an example

Usually with xamp you get to your test site using http://localhost/

Zen-Venom Get Bitten

17 May 2015, 3:15 AM
#3
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

Correct syntax for a host file would be:

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.

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

17 May 2015, 5:30 AM
#4
shopserver avatar

shopserver

New Zenner

Join Date:
Jan 2007
Posts:
23
Plugin Contributions:
0

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

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

17 May 2015, 6:31 AM
#5
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

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.

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:

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.

##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.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

17 May 2015, 6:39 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

but still https://www.example.com/ does not work
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"

Zen-Venom Get Bitten

17 May 2015, 10:41 PM
#7
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,114
Plugin Contributions:
56

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

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

18 May 2015, 8:04 AM
#8
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

I then access the "website" as localhost/zen_cart_directory_name

So you have a virtualhost per dev site to "catch" that url/address?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

18 May 2015, 8:29 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,114
Plugin Contributions:
56

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

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.

19 May 2015, 7:53 AM
#10
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

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.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

20 May 2015, 6:03 PM
#11
shopserver avatar

shopserver

New Zenner

Join Date:
Jan 2007
Posts:
23
Plugin Contributions:
0

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

Thanks for your help. I'm trying to get http://www.example.com/ working in the browser so http://www.example.com/xampp works (ref page 18 of the Zen Cart book by Goh Koon Hoek) in order to configure the Mercury mail server etc. My files are now set as follows:

hosts

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

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

The C:\xampp5680-portable\apache\conf\httpd.conf and C:\xampp5680-portable\apache\conf\extra\httpd-vhosts.conf are now configured as recommended by torvista above, but still the error message displayed is "This domain is established to be used for illustrative examples in documents".

My apologies if I'm missing something obvious, but I would like to get http://www.example.com/ working.

Thanks

John

20 May 2015, 6:47 PM
#12
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

shopserver:

Thanks for your help. I'm trying to get http://www.example.com/ working in the browser so http://www.example.com/xampp works (ref page 18 of the Zen Cart book by Goh Koon Hoek) in order to configure the Mercury mail server etc. My files are now set as follows:

hosts

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

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

The C:\xampp5680-portable\apache\conf\httpd.conf and C:\xampp5680-portable\apache\conf\extra\httpd-vhosts.conf are now configured as recommended by torvista above, but still the error message displayed is "This domain is established to be used for illustrative examples in documents".

My apologies if I'm missing something obvious, but I would like to get http://www.example.com/ working.

Thanks

John
Like the error message tells you, you have to use something else, because example.com is used for examples. Choose any you like, but not example.com.

20 May 2015, 7:10 PM
#13
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

shopserver:

... My apologies if I'm missing something obvious ...

lhungil:

... 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). ...
Note the part in red.

I understand you want to be able to exactly follow the tutorial you are referencing, but mapping a real domain (such as example.com) to 127.0.0.1 (loopback IP) should be avoided. Just use "example.local" instead of "example.com" and save yourself some headaches (.local is reserved for local use and will not be resolved by the root DNS servers).

Otherwise you will need to familiarize yourself with Windows DNS resolution, the Windows DHCP client (one may need to manually override the resolution order depending upon what the DHCP server sent), how to flush the Windows DNS cache, and potentially some other topics as well.

NOTE 1: Many examples / guides will use "example.com". They usually intend for you to replace "example.com" with a different domain name.

NOTE 2: Usually the order on Windows is "cache", "hosts file", "DNS", etc. However many different items can impact the resolution order including not only the local computer settings but also settings pushed: via group policy, by the DHCP server, by malware protection software, and the list goes on.

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

21 May 2015, 6:13 AM
#14
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Windoews 8 XAMPP setup ...etchosts config ok but www.example.com doesn't redirect

My apologies if I'm missing something obvious, but I would like to get http://www.example.com/ working.
As I and others have stated example.com is only used for "example" and not intended to be functional
lhungil has outlined best what would be required to make xamp a fully functional host base capable of using FQDN(fully qualified domain name).
xamp is not intended to be used in this way and is only for testing locally

Zen-Venom Get Bitten