How to do a SSL redirect with htaccess *solved*

Hi guys,

I’d like to use SSL with my website. I can quite easily purchase SSL via Hosteurope (german provider), but I got told that I need to ask my web developer (cough that’s me cough) how to implement it, so that visitors of my site will be automatically forced to use the https://… when visiting my website. The guy at the hotline said something about htaccess… I have no idea and am in dire need of some help here :wink:

Does anyone know how to do that?


Thanks to Jan, my question got already solved. Thanks again :slight_smile:

Here’s 3 lines of code, that - once put into the .htaccess file - redirects to the https version of the site, once the ssl certificate is active. Works for me.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Hope that helps if anyone else with this problem is searching for a solution.

1 Like

Thanks for starting this thread, but hope its ok for me to ask this question… where do I find the .htaccess file?

It’s generally in the root folder of your site e.g. public_html. However there is no guarantee it already exists so you may need to create it as well as add the content.

So long as your hosting account is using Apache or compatible (most do). I have one site that is on an MS server product and does not work with htaccess files :persevere: - Migrating shortly!

1 Like

Thank you for your help wirrah

One thing to point out with an .htaccess file is that it’s commonly hidden, so you may have to toggle its visibility back on in order to see it!

In the FTP program I use to look at websites, it’s under the Listing menu and is called Toggle Hidden Files.

1 Like

What the others said. The file didn’t exist on my server, so I had to create it. And all files beginning with a . on Mac OSX and probably on the server as well, are invisible. So you might not see it, even if it’s there.

1 Like