Mobile app version of vmapp.org
Login or Join
Rambettina238

: Redirection rule not working in .htacces I have added the following rule to .htaccess RewriteCond %{HTTP_HOST} !^example.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*)

@Rambettina238

Posted in: #301Redirect #Htaccess

I have added the following rule to .htaccess

RewriteCond %{HTTP_HOST} !^example.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) www.example.com/ [R=301,NC,L]


I suppose it says that if url is not example.com, redirect it to example.com.

I need to do this as I have a Cname example.rhcloud.com and is mapped to example.com. But I still can access example.rhcloud.com and is being indexed by Google as well. I certainly do not want my data to be available on 2 different domains and want example.rhcloud.com to be redirected to example.com
With above rewrite rule, it does nothing and gives access to example.rhcloud.com.

I also tried using

RewriteCond %{HTTP_HOST} ^example.rhcloud.com$
RewriteRule (.*)$ www.example.com/ [R=301,L]


But it says too many redirects as it try and retry to connect to example.rhcloud.com.

How do I have this redirect work?

Also, If that makes any difference, I have added WordPress URL and site URL set to example.com only.

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Rambettina238

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme