8

I plan to have 2 separate domain names pointing to the same Apache installation with WordPress multi-site.

I can set virtual hosts correctly for each domain, no problems. I can have both domains point to the same host, no worries.

Currently I have a redirect for all traffic hitting the web server IP address to my initial domain:

<VirtualHost *:80>
<Directory "/share/Web/WordPress">
        Options FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
</Directory>
        ServerName 1.1.1.100
        Redirect / https://www.example.com/
</VirtualHost>

What is the best practice for redirecting the IP address when 2 domain names point to the same IP?

I thought about creating a generic 404 page and having that displayed when hitting the IP address. But would this hurt my SEO on both sites?

How do shared hosting companies redirect HTTP traffic based on an IP address? Do they point back to the parent company, or something else? Perhaps this is a non issue all together?

So just to be clear: what is the best practice for redirecting the IP address of a web server when it hosts multiple domain names?

  • 1
    Hosting companies that offer shared accounts typically have a number of sites hosted all on the same IP address using virtual hosts as you've done.. They point the IP address either to a default server page, default site, or an error page. In either case, that does not affect any other site SEO-wise. Search engines crawl sites individually based on domain or IP and do not associate either with each other. So yes, this is really a non-issue - pointing the IP address to one of the sites is just fine and will not impact the other site(s). – dan Nov 19 '17 at 4:53
  • An IP address is associated to a domain for addressing. An IP address, typically, is hosted on a computer. When a browser request is made, a request packet is created with the URL in the header. The packet is sent to the server port 80 for the HTTP protocol which the web server has binds to to handle the request. The web server must have a virtual host created to handle the domain name. It is the web server that handles the request by domain name and not IP address. Any unknown request, one where a domain name does not have a virtual host for, will be handled by the first site created. – closetnoc Nov 19 '17 at 5:29
  • This first site created is sometimes intentionally configured to handle IP address only requests or unknown requests. This is know as a default site. It is the default site or the first site created than can redirect IP address only requests. If you do not control of the default or first site crated you will not be able to handle IP address only requests. Your sites would be the only sites on the server. If not, then you will not have the level of control you seek. Does this help? Did I get your question correctly? Cheers!! – closetnoc Nov 19 '17 at 5:34
  • 1
    Thanks Dan, your comments answer my question. Sorry for the vaguesness. – Mike Nov 19 '17 at 5:40
  • 1
    @Mike I think this question could be helpful to others if it's clarified. I'm going to help edit it, and would suggest posting the answer you edited into it below as an answer instead and accept it when you can so that it's clear to others, and you earn some more rep here. – dan Nov 19 '17 at 5:48
7

The answer is in the comment:

Hosting companies that offer shared accounts typically have a number of sites hosted all on the same IP address using virtual hosts as you've done.. They point the IP address either to a default server page, default site, or an error page. In either case, that does not affect any other site SEO-wise.

For clarity redirecting the IP to an error page, 404 or another landing page is the best practice. None of which will negatively affect SEO of any domain hosted.

2

The answer to your question "What is the best practice for redirecting the IP address of a web server when it hosts multiple domain names?" is this: Best practice is to use a redirect (Apache) or return an error 444 (Nginx) to prevent host header attacks.

Your second question about SEO is irrelevant and has nothing to do with the title of your question, but you should ask a new question "Can redirecting requests for a server's IP address influence SEO?" if it worries you.

Here is an example for Apache:

<VirtualHost *:80>
  ServerName IP.AD.DR.ESS
  Redirect permanent / http://www.example.com/
</VirtualHost>

And here is an example for Nginx:

server {
  listen 80;
  server_name IP.AD.DR.ESS;
  return 444;
}

Both examples listen on port 80 only because redirecting HTTPS requests for the IP address on port 443 is not possible.

  • Hi Tom, in your example I would need a domain name for the Apache redirect. This does not answers my question. Also, returning a 444 from nginx and a redirect to another domain from Apache is 2 different behaviors for the same scenario, therefore does not sound like best practice. – Mike Nov 20 '17 at 11:07
  • You don't need a domain name for Apache, you can literally redirect to example.com instead of one of your domains if you prefer. On your second point, Apache does not support 444 errors, this is an Nginx thing. Preventing host header attacks is best practice, and different tools do it differently. Not sure I understand the logic in your comment but I hope that's clearer now? – Tom Brossman Nov 20 '17 at 13:35
  • Hi Tom, thanks for clarifying. I understand your point now. I believe host header attacks are not relevant here as there is no PTR dns record so the domain name does not resolve from the IP address. IMHO the answer in my answer is still viewed as best practice. – Mike Nov 21 '17 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.