Multiple domains and sub-domains pointing to one site?

Executive summary:

Ideally, is there a way to convince a single free 000webhost site to serve my four different domain URLs?

Failing that is there at least a way to get the old domain.com and www.domain.com support with one website?

Details:

I want to support legacy links which use two domains and their www subdomains.
http://apptllc.com
http://www.apptllc.com
http://alwayspositivepettraining.com
http://www.alwayspositivepettraining.com

I don’t want any broken links, but I am happy to have all those URLs permanently redirect to
http://www.alwayspositivepettraining.com

Pre-migration I used two 000webhost sites. One accepted queries to http://apptllc.com and http://www.apptllc.com then used .htaccess redirects to send everyone to the other site. The other accepted queries to http://alwayspositivepettraining.com and http://www.alwayspositivepettraining.com and served my actual content (simple static files). Other than the apptllc redirect everything site routinely getting shut down by 000webhost as inactive, this worked well enough that it was not worth spending time finding a cleaner solution.

Now I have tried to migrate, and as I post this I have a site accepting queries for www.alwaypositivepettraining.com or alwayspositivepettraining.000webhostapp.com. The domain is parked, but I have not been able to convince it to also accept queries for the simple alwaypositivepettraining.com version. Though that might be a DNS timeout issue.

I’ve also tried to park or point two domains at this site so I could host all four URLs from a single site, but the second LINK WEBSITE command seems to always unlink the previous domain.

I’ve setup a second website apptllc.000webhostapp.com, but that site always redirects to http://error404.000webhost.com/? with and without park and point variants, even with an empty .htaccess file and just an index.html file. I’m not sure if my problems there are a configuration issue at my end, or a result of the “Free Hosting Errors Are Being Worked On” issue in the forum banner. So I’m giving up on that for today (is there a way I can see diagnostic logs?).

Thanks in advance for any guidance.

@apptllc I see you used http rewrite rule in .htaccess to “alwayspositivepettraining.000webhostapp.com” to"www.alwaypositivepettraining.com", which is working fine.

This url loads fine too.

Clear your browser cache and data and then try again or use incognito mode in chrome.

If i’m missing something plz let me know.

If your user only accesses apptllc.com, www.apptllc.com, you can create a PHP script wrapper which will redirect to www.alwayspositivepettraining.com automatically.

<?php

if(!$_SERVER["SERVER_NAME"] == "www.alwayspositivepettraining.com"){
     header("Location: http://www.alwayspositivepettraining.com/index.htm", true, 301) ;
}

?>

Save this file as index.php, and place it in your public_html folder.

Hope this helps :slight_smile:

I appear to be up and fully operational using two free 000webhost websites similar to what I had before the migration. I did not find a way to support all my different domains using a single 000webhost website.

It looks like some of my issues were DNS cache, some of my issues were the 403,404 issues previously announced in the forum’s header, and some of my issues appear to be related to a much longer time than I expected from my running the “Set web address” page’s “Add domain” command to the change being fully implemented. While changes to an .htaccess file work essentially instantly, “Add domain” changes appear to sometimes take almost 24 hours to become fully effective.

For those interested in solving the same issue in the future, what follows is a description of the approach I took.

First create two 000webhost websites, in my case they are named alwayspositivepettraining.000webhostapp.com and apptllc.000webhostapp.com. All of the “content” being served to the public is in my alwayspositivepettraining website. Technically, all I really need is a public_html/.htaccess file in the apptllc website which simply redirects everything to the other website.

Note: Before the May 2017 migration to the new management interface 000webhost would periodically think my redirect site was “inactive” and would warn, then delete the site. The old workaround was to reset inactivity ads periodically, or recreate the website if I forgot to reset inactivity ads. I don’t know yet how this will workout with the new management interface.

So create your content and redirect site, in both websites add the following three lines to each website’s public_html/.htaccess file, obviously using your own domain name not mine. :slight_smile:

<If "%{HTTP_HOST} !~ /www\.AlwaysPositivePetTraining\.com/i">
    Redirect permanent "/" "http://www.AlwaysPositivePetTraining.com/"
</If>

See http://httpd.apache.org/docs/2.4/rewrite/avoid.html topic “Simple Redirection” for technical details. This approach redirects all URL’s that reach the website to the corresponding www.AlwaysPositivePetTraining.com URL preserving path information. So for example in my case:

https://apptllc.000webhostapp.com/any/path/file.html
http://APPTLLC.com/any/path/file.html
http://www.APPTLLC.com/any/path/file.html
https://alwayspositivepettraining.000webhostapp.com/any/path/file.html
http://AlwaysPositivePetTraining.com/any/path/file.html
all get redirected to
http://www.AlwaysPositivePetTraining.com/any/path/file.html
which does not get redirected further by those three lines. In most browsers this change will be shown in the browser’s address bar.

Use the “Add domain” functionality to park or point your preferred address to the website containing your content (www.AlwaysPositivePetTraining.com), and “Add domain” your alternative address (APPTLLC.com) to your redirect website. That part is identical to the generic 000webhost instructions. The second website is simply a workaround because as of this writing you cannot “Add domain” two different domains to the same free website successfully.

Note: After adding a domain you have to wait for two things. One is for your domain’s DNS information to be updated. DNS information has an adjustable cache timeout period. One day and one week are both popular timeout periods. Though if you control your own DNS and know you are going to be changing things next week, you could temporarily set the timeout to one hour. You will also have to wait for 000webhost to update their server’s virtual host information so that the servers know which website and thus which directory corresponds with which domain name. That part seemed to take almost 24 hours during my testing.

I hope this helps someone. If anyone comes up with a way to do all this with a single free 00webhost website, please let us know.

2 Likes