Results 1 to 6 of 6
  1. #1

    HTTP to HTTPS Redirect

    Hi folks,

    I had a script coded in CakePHP and I have just installed the SSL Cert on my particular page. I'm trying to create an HTTP to HTTPS redirect using the .htaccess file, but I only see the redirect on Google Chrome because Chrome automatically looks for the HTTPS. On all of the other browswers my redirect doesn't work.

    My current .htaccess file looks like this:

    # php_value memory_limit 256M

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ app/webroot/ [L]
    RewriteRule (.*) app/webroot/$1 [L]
    </IfModule>

    -------------------------------------

    I have tried using the following and variations of the following and nothing seems to work:

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

    -------------------------------------

    Any suggestions?

  2. #2
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    Try changing the condition to
    Code:
    RewriteCond %{HTTPS} off
    Fabin Mundattil @ Xieles Support
    High Quality Server Management | support @ xieles.com
    http://xieles.com

  3. #3
    Quote Originally Posted by fabin View Post
    Try changing the condition to
    Code:
    RewriteCond %{HTTPS} off
    That still doesn't work. It just sends the domain to http://www.domainname.com, not https://www.domainname.com.

  4. #4
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    write it above all existing rewrite rules
    Fabin Mundattil @ Xieles Support
    High Quality Server Management | support @ xieles.com
    http://xieles.com

  5. #5
    Quote Originally Posted by fabin View Post
    write it above all existing rewrite rules
    I'm still getting the same result. Just sends me to http://www.domain....

  6. #6
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,836
    1. Clear your browser cache after each .htaccess edit - redirects can and will be cached.
    2. Try a redirect to somewhere else (eg. http://google.com/?q=$1) just to make sure the rule is firing at all.

    Also,
    Quote Originally Posted by n0ts0smart View Post
    My current .htaccess file looks like this:

    # php_value memory_limit 256M

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ app/webroot/ [L]
    RewriteRule (.*) app/webroot/$1 [L]
    </IfModule>
    that looks like a recipe for an endless rewrite loop (request -> app/webroot/request -> app/webroot/app/webroot/request etc). You'd normally use a condition before that last rule, something like:
    Code:
    RewriteCond %{REQUEST_FILENAME} !-f
    I'd wonder if mod_rewrite (and / or .htaccess) is actually disabled, except that presumably the site wouldn't work without this rule?
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  7. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Similar Threads

  1. using htaccess to redirect from http to https. Please help!
    By zomex in forum Hosting Security and Technology
    Replies: 7
    Last Post: 06-17-2009, 08:08 AM
  2. how to force redirect https to http
    By grabmail in forum Programming Discussion
    Replies: 6
    Last Post: 12-13-2006, 02:09 PM
  3. Redirect from https >> http
    By MarkerMart in forum Programming Discussion
    Replies: 6
    Last Post: 07-22-2006, 04:16 AM
  4. .htaccess redirect : http to https
    By jon31 in forum Programming Discussion
    Replies: 7
    Last Post: 01-26-2006, 11:27 PM
  5. Redirect http to https
    By l0ck_up in forum Hosting Security and Technology
    Replies: 8
    Last Post: 11-09-2004, 12:41 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •