Zen Cart Logo
Forums / Installing on a Linux/Unix Server / Starts with wrong domain host name

Starts with wrong domain host name

Locked

Views: 2,573

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
28 May 2010, 7:29 PM
#1
meshgraphics avatar

meshgraphics

New Zenner

Join Date:
Mar 2008
Location:
Ontario
Posts:
42
Plugin Contributions:
0

Starts with wrong domain host name

I have a Zen Cart install v138a which starts up with a domain host name other than the one specified in config.php define HTTP_SERVER. Is that supposed to happen?

I don't think php could check the url. Is there javascript that is supposed to check that?

28 May 2010, 8:23 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Starts with wrong domain host name

It's not very clear what you mean.

In principle your configure.php file will contain the domain name you gave it when you installed or whatever you have since edited it to.

If you have multiple domains in your hosting account and have pointed more than one to the folder where your Zen Cart is installed, then they will all start your store.

I'm not sure what you mean by having javascript check for this, but since javascript runs in a visitors browser, there's not a lot that it can do about your server configuration.

28 May 2010, 8:39 PM
#3
meshgraphics avatar

meshgraphics

New Zenner

Join Date:
Mar 2008
Location:
Ontario
Posts:
42
Plugin Contributions:
0

Re: Starts with wrong domain host name

A little bit of js could derail the page if the url was unexpected.

No big deal. You can't check everything. Just one of those things to look out for, I guess.

29 May 2010, 10:01 AM
#4
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Starts with wrong domain host name

I'm not sure I would just let that go.

Is it possible your site has been hacked?

What exactly do you mean by 'starts up'? A completely different domain name appears in your address bar, then switches to the proper one? If so, have you looked at any .htaccess files and double-checked your configure.php files?

29 May 2010, 10:02 AM
#5
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,627
Plugin Contributions:
0

Re: Starts with wrong domain host name

The site URL could help us to give better advice.

29 May 2010, 12:10 PM
#6
meshgraphics avatar

meshgraphics

New Zenner

Join Date:
Mar 2008
Location:
Ontario
Posts:
42
Plugin Contributions:
0

Re: Starts with wrong domain host name

I reinstalled my LAMP on my local winxp but I dont see anything in the ZenCart code that would make Linux act any different.

In Apache you set the web dir whether its single or vhosts.

In your hosts file you define the hosts/domain name the web server will respond to.

You type the url into the browser and ZenCart php will start.

Ok, php can get the host name from the environment var SERVER_NAME. It should be comparing that with define HTTP_SERVER.

29 May 2010, 12:28 PM
#7
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Starts with wrong domain host name

OK ... but it's still not obvious to those of us who can't see your screen what the problem is, making it difficult to give any advice or help.

29 May 2010, 2:08 PM
#8
meshgraphics avatar

meshgraphics

New Zenner

Join Date:
Mar 2008
Location:
Ontario
Posts:
42
Plugin Contributions:
0

Re: Starts with wrong domain host name

If youve configured vhosts in Apache and you know some php youll know what I'm talking about.

When ZenCart starts up it does a lot of checks on the defines in the configure.php. If theres a problem, it throws up the Install ZenCart page or something like that.

Looking at a web page isn't going to help you. You need to trace the code.

When I get my debugger configured, I'll tell ya where.

29 May 2010, 2:15 PM
#9
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Starts with wrong domain host name

meshgraphics:

If youve configured vhosts in Apache and you know some php youll know what I'm talking about.I have. I do. But that doesn't make any clearer the problem you're asking about.

I'm sure that it's very obvious to you as you observe the behaviour, but to those of us who can't see it, your explanation is very vague and ambiguous.

But hey, I can think of better ways to spend my weekend than keep saying that, so I'm out of here.

29 May 2010, 5:29 PM
#10
meshgraphics avatar

meshgraphics

New Zenner

Join Date:
Mar 2008
Location:
Ontario
Posts:
42
Plugin Contributions:
0

Re: Starts with wrong domain host name

For those of you who dont know:

Apache Web Server has had the ability to host several domain name/hosts on a single web server for quite a while. This is accomplished through the vhosts configuration in the http.conf file.
Every domain configured on the server has a config section in the Virtual Hosts area. A minimum config would require

ServerName mysite.com
    DocumentRoot /home/user1/html_default
ServerName mysite22.com
    DocumentRoot /home/user22/html_default

When a browser asks the web server for http://mysite.com
it will run index.php at /home/user1/html_default.

If by mistake you had the same DocumentRoot for both websites, asking for either website would start the same index.php.

In fact, this may be what you want. If you want multiple domain names starting up the same site, this is what you would do.

Ok, lets suppose Zen Cart is going to check the servername after the php starts up. Apparently, is doesnt do that.

29 May 2010, 6:54 PM
#11
meshgraphics avatar

meshgraphics

New Zenner

Join Date:
Mar 2008
Location:
Ontario
Posts:
42
Plugin Contributions:
0

Re: Starts with wrong domain host name

////////// snip from application_top.php

/**
 * if main configure file doesn't contain valid info (ie: is dummy or doesn't match filestructure, display assistance page to suggest running the installer)
 */
if (!defined('DIR_FS_CATALOG') || !is_dir(DIR_FS_CATALOG.'/includes/classes')) {
  require('includes/templates/template_default/templates/tpl_zc_install_suggested_default.php');
  exit;
}

/**
 * 
Check requested domain name matches Zen Cart config.  Compliments of meshgraphics.com.
 */

if (!defined('HTTP_SERVER') || 'http://'. $_SERVER['SERVER_NAME'] != HTTP_SERVER){
  require('includes/templates/template_default/templates/tpl_zc_install_suggested_default.php');
  exit;
}
20 Aug 2010, 9:40 AM
#12
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Starts with wrong domain host name

meshgraphics:

If by mistake you had the same DocumentRoot for both websites, asking for either website would start the same index.php.

In fact, this may be what you want. If you want multiple domain names starting up the same site, this is what you would do.
Exactly right. Different domain names coming to the same front controller (index.php) may be a mistake, though it's more likely to be deliberate. For example I have clients who run two or more sites from the same Zen Cart. Some run multiple retail sites using the same products, one runs a retail and a wholesale site with a common sign on but different products and pricing depending on which domain the customer comes in on (and whether they are authorised for the wholesale site).
meshgraphics:

Ok, lets suppose Zen Cart is going to check the servername after the php starts up. Apparently, is doesnt do that.Also correct. If you choose to direct multiple domains at a single front controller, Zen Cart has to assume that you did it deliberately, so there's no corrective or specific action for it to take, and so no reason to perform the check.

21 Aug 2010, 1:59 AM
#13
mgswed avatar

mgswed

Banned

Join Date:
May 2009
Posts:
2
Plugin Contributions:
0

Re: Starts with wrong domain host name

includes/configure.php
admin/includes/configure.php