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 www. 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.


2 Answers 2


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/$1" [R=301,L]
  • So I need to create page rules? Can't I do it just using CNAMEs? Commented Jun 8, 2016 at 4:34
  • Since the OP wants to use only CloudFlare, Page Rules would be the way to go here. You actually can redirect URLs using variables and wildcards. See the bottom of this support doc from CloudFlare for examples: How do I perform URL forwarding or redirects with CloudFlare?
    – dan
    Commented Jun 8, 2016 at 4:34
  • @SomebodystillusesyouMS-DOS You'd need to use Page Rules. Using a CNAME would point one host to another, but not handle URL rewrites, which would need to be done via the web server otherwise (like matt pointed out above).
    – dan
    Commented Jun 8, 2016 at 4:38
  • @dan I don't know if my friend needs url rewrites, these domains were mainly to avoid copyright issues. I tried a CNAME pointing example.com.cc to example.com but it didn't work, I get "too many redirects" (ERR_TOO_MANY_REDIRECTS) error. Commented Jun 8, 2016 at 5:20
  • 1
    @SomebodystillusesyouMS-DOS as dan said above , don't use CNAME, Simple page rules in cloudflare would handle exactly what you want to do. 1 rule for each of the 2 domains to be redirected.
    – brass
    Commented Jun 8, 2016 at 14:26

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:



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

www.example.com/* Forwarding URL - 301 http://example.com/$1



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

www.example.com.cc/* Forwarding URL - 301 http://example.com/$1

example.com.cc/* Forwarding URL - 301 http://example.com/$1



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

www.example.com.co/* Forwarding URL - 301 http://example.com/$1

example.com.co/* Forwarding URL - 301 http://example.com/$1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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