: Redirection rule not working in .htacces I have added the following rule to .htaccess RewriteCond %{HTTP_HOST} !^example.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*)
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.
More posts by @Rambettina238
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.