Redirecting entire website from http to https …
-
Hi all,
Apologies for what might be a really stupid question, but I’d really appreciate some help please … π
Suppose that I have the website “http://example.com” (running WordPress and s2Member Pro) and I install an SSL certificate. Now, I know that in WordPress I need to go to “Settings” > “General” and change both the “WordPress Address (URL)” and the “Site Address (URL)” from “http://example.com” to “https://example.com”. I also know that I need to modify the “.htaccess” file (i.e. the one in my “public_html” folder) to ensure that if someone clicks on a link (e.g. displayed on my website, or on another website) to an “http” page on my website then they’ll be redirected to the corresponding “https” page on my website.
However, what I’m confused about is exactly what code I need to insert into the “.htaccess” file to achieve the above.
For example, an article on the s2Member website indicates that I need to insert the following code …
# BEGIN Force SSL <IfModule rewrite_module> RewriteEngine on RewriteBase / RewriteCond %{HTTPS} !^on$ [NC] RewriteCond %{HTTP:X-Forwarded-Proto} !^https$ [NC] RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule> # END Force SSL… whereas another website indicates that I need to insert the following code …
RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule .* https://example.com/%{REQUEST_URI} [R,L]… whereas another website indicates that I need to insert the following code …
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://example.com/$1 [R,L] </IfModule>Does anyone know why the above pieces of code are all different? Are they all different ways of achieving exactly the same thing, or is one of them correct and the others incorrect?
Thanks very much in advance,
Steve
The topic ‘Redirecting entire website from http to https …’ is closed to new replies.