.htacces and https


I’m using the following .htaccess and it works pretty well with my webhoster

Options +FollowSymLinks

IndexIgnore */*

RewriteEngine on

# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php

RewriteRule . index.php

Recently I install a SSL certificate to have and I would like to redirect the http traffics automatically to the https.

my hoster tell me to use that :

RewriteCond %{HTTP_HOST} ^(.*\.)*yourdomain.com$ [NC]

RewriteCond %{SERVER_PORT} !^443$

RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R]

But when i put those lines ( I replace with my domain) after the other ones it doesn’t work.

I tried several options to modify the .htaccess but nothing seems to work.

Do you have any idea?

If your provider allow you this is the correct method to do it in apache:


If this is not possible then you can use mod_rewrite


If you want to control the redirect inside you controller (ie only for some actions) you should use



Thx you Roberto It’s working !