Redirect from subdomain (ab-xyz.rhcloud.com) to custom domain

101 Views Asked by At

I want redirect my openshift subdomain (*.rhcloud.com) to my custom domain when my visitors access subdomain. I tried using .htaccess for redirect but I got an Redirect error on mozilla firefox. This is my .htaccess code:

RewriteEngine On 
RewriteRule ^(.*)$ http://customdomain.com/ [R=301]
1

There are 1 best solutions below

0
On

Try this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^app-domain\.rhcloud\.com [NC]
RewriteRule ^(.*)$ http://customdomain.com/$1 [R=301,NC,L]

You are missing where it looks for the old domain to redirect, so you are getting a redirect loop.