Mobile app version of vmapp.org
Login or Join
Mendez628

: Configure 3 domains in CloudFlare, with 2 redirecting to the first one, for a wordpress installation in openshift My friend has 3 domains: example.com example.com.cc example.com.co The website is

@Mendez628

Posted in: #Cloudflare #Cname #Dns #Redirects

My friend has 3 domains:


example.com
example.com.cc
example.com.co


The website is hosted at OpenShift and it's already redirecting example.com to it (using the guide in this answer). So far, so good. We are using CloudFlare in this setup.

We would like to know how to configure the other domains to redirect to the .com, using only CloudFlare, for a wordpress installation in openshift.

All nameservers have been changed at the domain registrars, and are set up to be used by CloudFlare to redirect to the .com, but I don't know exactly what I need to do. All the subdomains would be redirected to example.com as well.

There's a similar question here but the solution is to use the hosting control panel, something I don't want to do. My idea here is to use only CloudFlare, since for each domain a different registrar was used, and having all DNS configuration in a single place is better.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Mendez628

2 Comments

Sorted by latest first Latest Oldest Best

 

@Shelley277

Although matts answer gave me some direction for the "page rule" tip in cloudflare, a bunch of stuff still had to be made.

I'm assuming you already have an application running in openshift: let's suppose it's subdomain is php-example.rhcloud.com, and now you want to add custom domains example.com, example.com.cc and example.com.co to redirect to the application: remember that example.com.cc and example.com.co will redirect to example.com.

1 - Configure domain aliases for example.com, example.com.cc and example.com.co in the openshift web console;

2 - Create a Cloudflare account, adding example.com, example.com.cc and example.com.co as your domains;

3 - Go to your domain registrar (I'm using GoDaddy) and change the nameservers to the ones that were given to you when you were adding the domains in cloudflare (in my case it was alec.ns.cloudflare.com and june.ns.cloudflare.com);

4 - "Refresh" your domains in cloudflare, in the "Overview" section to check that cloudflare is now in charge of your DNS;

5 - Time to configure the DNS and Page Rules for your domains:

example.com

DNS

Type: CNAME
Name: example.com
Value: php-example.rhcloud.com

Type: CNAME
Name: www
Value: example.com

PS: Remember to check the cloud icon, it needs to be orange.

Page Rules
example.com/* Forwarding URL - 301 example.com/
example.com.cc

DNS

Type: CNAME
Name: example.com.cc
Value: php-example.rhcloud.com

Type: CNAME
Name: www
Value: example.com.cc

PS: Remember to check the cloud icon, it needs to be orange.

Page Rules
example.com.cc/* Forwarding URL - 301 example.com/
example.com.cc/*
Forwarding URL - 301 example.com/
example.com.co

DNS

Type: CNAME
Name: example.com.co
Value: php-example.rhcloud.com

Type: CNAME
Name: www
Value: example.com.co

PS: Remember to check the cloud icon, it needs to be orange.

Page Rules
example.com.co/* Forwarding URL - 301 example.com/
example.com.co/*
Forwarding URL - 301 example.com/
That's it: when you use https, an invalid certificate will issue because you're using a custom domain (example.com) but the certificate is for php-example.rhcloud.com: for you to use custom ssl certificates on the server, you need Bronze or Silver plan from openshift or use Cloudflare certificate.

10% popularity Vote Up Vote Down


 

@Caterina187

If you don't need to redirect mydomain.com.co/url-example to mydomain.com/url-example then some simple page rules in cloudflare for the 2 other domains to do a 301 redirect back to the main domain would do the trick.

If you need to redirect with url, the ideal case would be to set up server with 3 virtual hosts with the domains. When user visits a domain to be redirect the .htaccess file redirects them with 301 to the correct domain.

For mydomain.com.cc use the following:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com.cc$ [NC]
RewriteRule ^(.*)$ "https://www.mydomain.com/" [R=301,L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme