There is this WordPress application on OpenShift that uses CloudFlare as DNS server.

OpenShift gives us a URL such as and allow you to add alias. Such as So you have to add CNAME entries to your domain pointing to My registrar didn't allow me to add CNAME without a subdomain (without www.) so I moved my DNS Servers to CloudFlare and added the CNAMEs there.

registrar -> CloudFlare -> OpenShift

The WordPress application has a .htaccess to rewrite URL and makes it more friendly. The application configuration is set up to redirect any to a ROOT URL, in my case, I choose to redirect to and this should work. But I started facing a redirect loop problem. I tried to do the redirect myself, at the first line of index.php file, but it also failed. Then I stopped using the Location in the headers to redirect and started with Refresh. This was the most effective, but stops working in a few hours. Then I forced a no-cache version as explained here Didn't work.

I started trying things with .htaccess, checking some rules and conditions to force the before the application tried to redirect, but it also causes the same loop. The URL never changes, both with .htaccess and with PHP.

I then tried the following: without rewriting URLs AND/OR with an empty .htaccess there is no friendly URL, but no redirect loop as well.

Any Ideas on how to solve this? It's been over 2 weeks since I started installing this app, and I have to point non-WWW requests to HTTP://WWW



Just to make it clearer: I can't add HTTP://WWW to non-WWW urls, so it creates a redirect loop. When page is reloaded without the http://www it makes the redirect AGAIN. And again and again. This is the real problem.

  • How did you configure WordPress? – Michael Hampton Sep 25 '15 at 3:34
  • it's the default configuration. default .htaccess and Wordpress Address and Site Address are do you need some particular information? – Victor Ferreira Sep 25 '15 at 3:41
  • shows you redirecting non-www to non-www – Jacob Evans Sep 25 '15 at 3:41
  • yes, because it's not adding the www me and wordpress say it to do. the header() function and the non-www to www .htaccess are not working. you can cURL and the redirect doesnt include www – Victor Ferreira Sep 25 '15 at 3:43

You could try setting your A record to a 3rd party 301-www host

1) Do it with CloudFlare

2) use a 301-www IP from Duda = IN A

3) check your .htaccess and post it here

4) Also check out the Wordpress community.

  • i Don't have a unique IP with OpenShift it's shared I suppose, or it can change any day. I just add this RewriteCond %{HTTP_HOST} ^$ RewriteRule (.*)$1 [R=301,L] to my htaccess right after RewriteEngine On and check it again... same problem (solution from the link at wordpress community you posted) – Victor Ferreira Sep 25 '15 at 3:48
  • the IP address I gave you ONLY DOES 301 to www, nothing else, I'm actually researching anycast vps, I may just host one for people to use. – Jacob Evans Sep 25 '15 at 3:54
  • @VictorFerreira Op1(edited) may be what you want. – Jacob Evans Sep 25 '15 at 4:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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