Im looking to redirect all traffic on my site to the https version and been struggeling with the .htaccess file for quite some time now. I have it partially working, but not 100% What i want is to redirects both http:// and http://www. traffic to the https://www. version of the site. ( in a seo friendly way) I added this to my .htaccess file: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L] this redirects "http" traffic to the "https://www" version if the site ( which is good) BUT i also want to redirect http://www. trafic to the https://www. version of the site. Does anyone have a clue on how to do this? any ideas are much apreciated!
Try with the following code RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] Code (markup):
Thanks RoseHosting, this works fine But this is a port based redirect ( port 80) I really would like a URL/Directory based redirect ( for seo reasons) Any way this can be done?
How about something like this: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} Code (markup): Cheers!