How to redirect http to https (port 80 to 443) with Apache 2.2 on Debian Lenny

Friday, 16th April 2010

If you’re about to configure a redirect of http to https, just like I was required to on a Debian server. You’ll probably wonder how to achieve that, just like I wondered today.
There are plenty of ways to solve the task, first thing that poped up on my mind was to use PHP redirect, however I rethinked over it and reconsidered that using php redirect is too heavy for the server in terms of performance.
This way though it’s quick and easily achievable would execute the php code each time accessed, this on a loaded server will create a real performance issues.
Therefore I considered on to achieve the task on Apache level.
After a quick research on google I find the quick solution.
The whole solution comes to adding two lines of code to either your VirtualHost or the apache2.conf (on Debian) or httpd.conf or any name your Linux or FreeBSD distrubtion users for the Apache configuration file.

Redirect permanent / https://domain.com/

That’s all now just restart Apache.

debian-server:~# /etc/init.d/apache2 restart

There you go your http to https redirect should be now in action.

Share this on:

Download PDFDownload PDF

Tags:

One Response to “How to redirect http to https (port 80 to 443) with Apache 2.2 on Debian Lenny”

  1. tttony says:
    Firefox 3.0.19 Firefox 3.0.19 Windows XP Windows XP
    Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19 (.NET CLR 3.5.30729)

    That’s it is simple because your site it is secure all time, but when only you have for example an users manager and just need the login page secure, I have no tested yet but you can use in that action Rewrite rules with Regular expresions, is not complicated

    View CommentView Comment

Leave a Reply

CommentLuv badge