Author Topic: redirection to https  (Read 5515 times)

Offline renevdb

  • Newbie
  • *
  • Posts: 8
redirection to https
« on: September 16, 2006, 02:31:09 AM »
Hi,

JUst want to redirect all traffic in my webmail.domain.com to https and changed the .htaccess but this doesn't work.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

# AddDefaultCharset   UTF-8
#php_flag    display_errors Off
php_flag    log_errors   On
php_value    error_log    logs/errors
#php_value   upload_max_filesize   2M


 Order allow,deny
 Deny from all


Order deny,allow
Allow from all

What am I missing. I have no access to http.conf so I need to do it in .htaccess.

thanks!!
Eddie would go !

Offline ipstatic

  • Newbie
  • *
  • Posts: 4
Re: redirection to https
« Reply #1 on: September 17, 2006, 12:13:37 AM »
I just figured this out myself. I am using this in my httpd.conf but it should work in a .htaccess as well:

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

Hope this works!

Offline renevdb

  • Newbie
  • *
  • Posts: 8
Re: redirection to https
« Reply #2 on: September 17, 2006, 01:45:48 PM »
The rules work, but when used with the other rules in the .htaccess from roundcube it doesn't
Eddie would go !

Offline ipstatic

  • Newbie
  • *
  • Posts: 4
Re: redirection to https
« Reply #3 on: September 17, 2006, 05:06:29 PM »
Do you have these rules as the last set of rules? the letter L in the brackets [R=301,L] means that this rule is the last rule. So make sure these are the last rules.

Offline tcsoft

  • Newbie
  • *
  • Posts: 7
Re: redirection to https
« Reply #4 on: November 06, 2006, 03:25:21 PM »
and for all those people who are using lighty for example:
add the following lines to index.php

Code: [Select]
if( !isset( $_SERVER["HTTPS"] ) ){
 header( "Location: [url]https://"[/url] . $_SERVER["HTTP_HOST"] );
 exit();
}

Offline ipstatic

  • Newbie
  • *
  • Posts: 4
Re: redirection to https
« Reply #5 on: November 06, 2006, 03:56:23 PM »
and for all those people who aren't using lighty for example:

I am using apache, not lightpd. That code will work with apache and mod_rewrite.

Offline tcsoft

  • Newbie
  • *
  • Posts: 7
Re: redirection to https
« Reply #6 on: November 06, 2006, 04:24:06 PM »
Quote from: ipstatic
and for all those people who aren't using lighty for example:

I am using apache, not lightpd. That code will work with apache and mod_rewrite.
sry, corrected my post. wanted to say "people who are using lighty"

Offline ipstatic

  • Newbie
  • *
  • Posts: 4
Re: redirection to https
« Reply #7 on: November 06, 2006, 07:35:30 PM »
Thats cool, I didn't know if thats what you ment.