hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : HTTP to HTTPS Redirect
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

HTTP to HTTPS Redirect

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 11-15-2011, 10:30 PM
n0ts0smart n0ts0smart is offline
WHT Addict
 
Join Date: Apr 2010
Posts: 111

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?

Reply With Quote


Sponsored Links
  #2  
Old 11-15-2011, 11:26 PM
fabin fabin is offline
Web Hosting Evangelist
 
Join Date: Mar 2009
Location: Gods Own Country
Posts: 530
Try changing the condition to
Code:
RewriteCond %{HTTPS} off

__________________
Fabin M @ Xieles Support
High Quality Server Management | support @ xieles.com
http://xieles.com

Reply With Quote
  #3  
Old 11-15-2011, 11:29 PM
n0ts0smart n0ts0smart is offline
WHT Addict
 
Join Date: Apr 2010
Posts: 111
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.

Reply With Quote
Sponsored Links
  #4  
Old 11-15-2011, 11:42 PM
fabin fabin is offline
Web Hosting Evangelist
 
Join Date: Mar 2009
Location: Gods Own Country
Posts: 530
write it above all existing rewrite rules

__________________
Fabin M @ Xieles Support
High Quality Server Management | support @ xieles.com
http://xieles.com

Reply With Quote
  #5  
Old 11-15-2011, 11:46 PM
n0ts0smart n0ts0smart is offline
WHT Addict
 
Join Date: Apr 2010
Posts: 111
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....

Reply With Quote
  #6  
Old 11-16-2011, 12:21 AM
foobic foobic is offline
Community Liaison 2.0
 
Join Date: Feb 2005
Location: Australia
Posts: 5,149
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

"Learn from the mistakes of others. You can never live long enough to make them all yourself." - Groucho Marx

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
using htaccess to redirect from http to https. Please help! zomex Hosting Security and Technology 7 06-17-2009 08:08 AM
how to force redirect https to http grabmail Programming Discussion 6 12-13-2006 02:09 PM
Redirect from https >> http MarkerMart Programming Discussion 6 07-22-2006 04:16 AM
.htaccess redirect : http to https jon31 Programming Discussion 7 01-26-2006 11:27 PM
Redirect http to https l0ck_up Hosting Security and Technology 8 11-09-2004 12:41 AM

Related posts from TheWhir.com
Title Type Date Posted
50d7e27f-f654-4b4a-9c94-45d445a799a0 Listing 2013-03-05 18:24:25
50d7e27f-9f18-494f-800d-45d945a799a0 Listing 2013-03-05 18:24:25
50d7e27e-0acc-45d9-b46a-45bc45a799a0 Listing 2013-03-05 18:26:09
50d7e27e-f58c-4308-a359-45ca45a799a0 Listing 2013-03-05 18:24:23
Google Adds EU Cluster, SSL Encryption to App Engine Platform Web Hosting News 2012-06-29 11:16:18


Tags
https, redirect, ssl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?