Reputation: 53
I have used CloudFlare and setup SSL for my site using ReallySimpleSSL plugin and everything went fine except the site now doesn't redirect the www version to the naked version, which was my preferred domain and the one currently used in Webmaster Tools.
I have used this code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
I was using this code before I moved to https which was working well for redirecting www to non www.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
I would really appreciate any help with this because my site receives quite a traffic and I don't want to mess it up.
Regards, Naser.
Upvotes: 0
Views: 149
Reputation: 18671
With Cloudflare, It is easier to use their rules (Cloudflare -> Page Rules -> Forwarding URL 301)
If you do not want to use Cloudflare rules, you can use:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
</IfModule>
Upvotes: 1