Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Two sites on a dedicated server with one IP address

Best practice



7:53 pm on Nov 2, 2011 (gmt 0)

10+ Year Member

Currently I have two sites on an Apache server - one old and established and the other recently completed and about to be launched.

The IP address of the server currently redirects to the older site.

Is this a good idea, or should the IP not redirect to either URL?


9:09 pm on Nov 2, 2011 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Is the site soooo old that actual humans are referencing it by IP rather than domain name? (I met one recently that, as far as I could make out, didn't even have a name. Retro is fine, but let's not overdo it!) Or are you just dealing with robots?

Generic rule: If it's a legitimate request from a legitimate visitor, it needs to be redirected somewhere. And obviously the "somewhere" can't be the server itself.

In general, humans aren't expected to know from IP addresses. I'd just keep things the way they are. I can't think of any reason why humans would ask for the new site by IP when they don't even know what its IP is.


9:17 pm on Nov 2, 2011 (gmt 0)

10+ Year Member

Thanks Lucy. I had a feeling that would be the conclusion.

Can I ask which line needs to be modified in the. htaccess in order to remove the IP redirection to URL:

# Redirect index.htm/.html to '/'
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?(\?[^\ ]+)?\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.example.com/$1? [R=301,L]

# Redirect to remove multiple slashes within URL-path
RewriteRule ^(([^/]+/)*)/+(.*)$ http://www.example.com/$1$3 [R=301,L]

# Redirect to remove multiple slashes before URL-path
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* http://www.example.com/%1 [R=301,L]

# If not already redirected above, redirect non-canonical domain requests to the canonical domain
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

Thank you!


11:03 pm on Nov 2, 2011 (gmt 0)

5+ Year Member

None of those rewrite rules are directing IP to name.

Assuming Apache, you may have a VirtualHost entry pointing to the IP by name to your website document folder.

Below is how I send my direct IP requests to a file other than my primary site.

In /var/www/html, I just have a generic index.html file that says whatever. If the request comes in with my website hame, it goes to /var/www/mysite:


#### default catches ip only
DocumentRoot /var/www/html

#### mysite.com
DocumentRoot /var/www/mysite
ServerName www.mysite.com
ServerAlias mysite.com
ErrorLog logs/mysite-error.log
CustomLog logs/mysite-access.log combined


12:34 am on Nov 3, 2011 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

None of those rewrite rules are directing IP to name.

Ugh, yes, it's probably being done via the generic "non-canonical domain requests" rule. But that will need to be changed anyway, since you've now got more than one domain passing through the same htaccess. Otherwise you'll have requests for the new domain being redirected to the old domain too!

That makes the previous question a little more pointed. Do you actually have real live humans asking for the old domain by IP (this information will be in your raw logs), or were you just covering all possible bases?


12:44 am on Nov 3, 2011 (gmt 0)

10+ Year Member

Just covering all possible bases. I had no intention of hosting a second site on the same server, but it's proved to be an extremely fast and responsive setup. My homepage - which is a fair size and includes javascript - loads in around 0.5 seconds. So I thought it would be best not to take a second server for the second site.

At present there are two domain 'folders' - each has it's own .htaccess.

But wait .. if I have two .htaccess files each with largely similar content, aren't they both fighting over which gets the IP address?


2:18 am on Nov 3, 2011 (gmt 0)

5+ Year Member

There are many setups for how a web server will handle IP only requests. But typically if there are multiple sites on an single IP address, and that is very common, the server will not direct the IP only request to any one of them, but instead to a catch all page, which may be its own site that does not resolve by name.

It's best practice to never have any inbound links or references to a site by IP address only. It may have been more common many years ago when it was more typical to have a single site on a single IP. Over the years it became more common to run multiple, sometimes hundreds or even thousands of websites on a single IP. In that case the administrator typically would setup any request that goes directly to the IP to end up on a catch all page. Which is essentially what I do on my VPS's.

It sounds like you have a single site, and the server sends traffic by name or by IP to it. If you have no inbound links or users that have bookmarked or access your site directly via the IP address, then it would be safe set it up so the IP only request goes to a catch all page, or keep it like it is. Either way if they do not access it directly via IP it should not matter. I personally prefer to have IP only go to a catch all page.

The new second site that you are setting up should never be accessed by IP only, so it probably does not matter one way or the other if a direct IP call goes to the first site or catch all page, as far as the second site is concerned.

Featured Threads

Hot Threads This Week

Hot Threads This Month