Results 1 to 6 of 6
Thread: HTTP to HTTPS Redirect
-
11-15-2011, 10:30 PM #1WHT Addict
- Join Date
- Apr 2010
- Posts
- 153
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?
-
11-15-2011, 11:26 PM #2Web Hosting Master
- 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
█ https://xieles.com
-
11-15-2011, 11:29 PM #3WHT Addict
- Join Date
- Apr 2010
- Posts
- 153
That still doesn't work. It just sends the domain to http://www.domainname.com, not https://www.domainname.com.
-
11-15-2011, 11:42 PM #4Web Hosting Master
- 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
█ https://xieles.com
-
11-15-2011, 11:46 PM #5WHT Addict
- Join Date
- Apr 2010
- Posts
- 153
I'm still getting the same result. Just sends me to http://www.domain....
-
11-16-2011, 12:21 AM #6Retired Moderator
- Join Date
- Feb 2005
- Location
- Australia
- Posts
- 5,849
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,
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
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
Similar Threads
-
using htaccess to redirect from http to https. Please help!
By zomex in forum Hosting Security and TechnologyReplies: 7Last Post: 06-17-2009, 08:08 AM -
how to force redirect https to http
By grabmail in forum Programming DiscussionReplies: 6Last Post: 12-13-2006, 02:09 PM -
Redirect from https >> http
By MarkerMart in forum Programming DiscussionReplies: 6Last Post: 07-22-2006, 04:16 AM -
.htaccess redirect : http to https
By jon31 in forum Programming DiscussionReplies: 7Last Post: 01-26-2006, 11:27 PM -
Redirect http to https
By l0ck_up in forum Hosting Security and TechnologyReplies: 8Last Post: 11-09-2004, 12:41 AM