I have got two domains freemindcafe.com and freemindscafe.com registered in my name. I would like to redirect all the requests coming from following sources to the same ip address and port.
- freemindcafe.com
- freemindscafe.com
- www.freemindcafe.com
- www.freemindscafe.com
- *.freemindcafe.com
- *.freemindscafe.com
One approach is to update the DNS records so that both these domains points to the same ip address.
-
This will work but the only issue is that the users will see two different addresses in browser’s address bar one having freemindcafe and other freemindscafe.
-
The other disadvantage is that if we are setting authentication via google/facebook etc; we will have to provide a callbacck url. Now over there we can provide a single call back url, but because of url redirection one time the call back url will be freemindcafe and the other time the call back url will be freeminscafe
Solution
- I am using the digital oceans service, so my examples are based on that.
- We need to make sure that both the domains are pointing to the same ip address.
DNS Records for freemindscafe.com
DNS Records for freemindcafe.com
-
Once both the domain points to the same ip adrress, at your web server you will have to make sure to forward one domain to the other domain. I am forwarding freemindcafe.com to freemindscafe.com.
Using nginx as webserver and doing the http redirection ####contents of nginx xonfiguration file server_names_hash_bucket_size 64; server { server_name *.freemindcafe.com; rewrite ^/(.*) http://www.freemindscafe.com/$1 permanent; #return 301 http://www.freemindscafe.com$1; }