Http to https htaccess code?

Hello. It’s been awhile. Chrome now gives warnings to non https urls. Getting a SSL seems easy enough. But what’s the preferred htaccess code to change all the http to https?

Long standing sites - I don’t want to loose any SEO link juice. And anything else I need to consider (as far as contact forms or other) while I’m at it? Thanks!

I think the preferred code might vary based on your particular server settings, but the following gives the gist:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]

If HTTPS is off, rewrite to https://(the url) using a permanent redirect (R=301) to preserve ‘link juice’.

If your contact forms are using relative links (for their action= value), they should be fine, and even if they aren’t their request should be redirected to https anyways.

Links to media from other sites that are not https may trigger a subtle “Mixed Content” warning from the browser.

If you rewrite to https without a valid certificate, most browsers will not load the page and will advise users to go back.

It is advisable NOT to have this, and the closing </IfModule> in your .htaccess file as it can place a considerable load on the server. Check if your server has ModRewrite and if it has use the directives; if not, don’t.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.