39

Desired Behaviour

I have a GoDaddy domain name and am using OpenShift for hosting.

I would like the following to be true:

a) user enters www.mysitename.com > user sees mysitename.com

b) user enters www.mysitename.com/about.html > user sees mysitename.com/about.html

c) user enters mysitename.com or mysitename.com/about.html and they also see that url.

d) to summarise, the www prefix is never displayed anywhere on the site.

Constraints

OpenShift hosting does not have a static IP, so it is not possible to adjust the A record at GoDaddy.

The format for the OpenShift app is http://appname-username.rhcloud.com.

You can set up a cname at GoDaddy with the following:

www > appname-username.rhcloud.com

This means the site is accessible at www.mydomain.com but not at mydomain.com.

Suggested Solutions

There are several posts on the topic that suggest the following but for several reasons are not adequate solutions:

Question

Can anyone think of another solution that satisfies the desired behaviour stated above?

Or do I need to change to a registrar that allows "naked cname records"?

Related Posts

https://stackoverflow.com/questions/18431034/godaddy-domain-pointing-to-openshift-hosting
Naked domain with Openshift
How do I add an alias for a naked domain with OpenShift?

Edit

This blog posts sums up the scenario:

http://blog.cloudflare.com/zone-apex-naked-domain-root-domain-cname-supp

Could I sign up for CloudFlare to resolve the issue?

I haven't used it before and don't know how it works.

4 Answers 4

40

Solution

01) Sign up to cloudflare
02) Set these cname rules:

mydomain.com > appname-username.rhcloud.com (this will utilise 'cname flattening')

www > mydomain.com

03) Set page rules:

http://www.mydomain.com/* > http://mydomain.com/$1

04) Set alias in OpenShift to mydomain.com

05) Make sure GoDaddy DNS record doesn't have any conflicting cname or A record set up.

06) Let it simmer overnight and all of the original desired behaviour should be working.

4
  • Sorry for my ignorance, but what would be a conflicting cname or A record? The only record I have at the moment is this cname rule: www > blabla-blablabla.rhcloud.com. Since I bought my domain from GoDaddy I suppose I still need to have a rue setup over there. Is it ok like this or should it look different?
    – Ariel
    Apr 3, 2015 at 10:18
  • Yes. That works. Check for the page rules. That makes every thing works. select forwarding in the select box in cloudflare
    – Shobi
    Jun 25, 2016 at 10:49
  • I followed these steps and now it's redirecting to 'https' and '/app' on my rhcloud url. Any hint?
    – Azghanvi
    Jul 5, 2016 at 11:33
  • @Azghanvi use set the alias in web console of opeshift to www.domain.com Jul 31, 2016 at 6:55
26

Here is what worked for me.

Domain name : example.com
openshift app: myapp-mydomain.rhcloud.com

--on godaddy
      Domains>All Domains>select your domain example.com>click DNS ZONE FILE tab
      1. delete www CNAME
      2. create new Record with 
         Record Type CNAME > HOST: www > POINT TO: myapp-mydomain.rhcloud.com
      3. click Finish 

      Click Settings tab
      1. Forwarding > click Manage
         Forward to:www.example.com > Redirect: 301 (Permanent) > Type: Forward only
      2. click ADD

--on Openshift
      1. select Application tab > select application myapp-mydomain.rhcloud.com        
         > click change
      2. enter Domain name www.example.com

That's it. Wait for 10-15 min and see the magic.

4
  • It is forwarding to example/com/app i) https was not there ii) /app is incorrect Any hint to resolve it?
    – Azghanvi
    Jul 5, 2016 at 10:44
  • @Azghanvi use www.example.com with www in alias in openshift web console Jul 31, 2016 at 6:13
  • It does not get rid of the 'www' but provides an easy workaround. Thanks!
    – Archy
    Oct 11, 2016 at 8:35
  • This worked for me, needed exactly this!!!! thank you!!!
    – Hafiz
    Jan 18, 2017 at 21:46
7

To get your domain (with 'www' and without), to successfully point to your OpenShift alias, without 'masking' or 'forwarding' see this tutorial I wrote:

It works with CNAME Flattening.

2
  • 3
    Ugh. Dead link: Error 1001 Ray ID: 241659d5a94e11a1 • 2015-11-07 04:38:50 UTC
    – zipzit
    Nov 7, 2015 at 4:40
  • I have just edited my answer with a correct working link. Try it again. Dec 20, 2015 at 22:35
0

@Azghanvi: I faced the same problem. Make sure you add "www.example.com" as your alias in openshift and not "example.com". Seems like Godaddy does not support "example.com" by default.

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