Portal Home > Knowledgebase > Articles Database > HTTP to HTTPS Redirect


HTTP to HTTPS Redirect




Posted by n0ts0smart, 11-15-2011, 10:30 PM
Hi folks, I had a script coded in CakePHP and I have just installed the SSL Cert on my certain 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 RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] ------------------------------------- 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?

Posted by fabin, 11-15-2011, 11:26 PM
Try changing the condition to

Posted by n0ts0smart, 11-15-2011, 11:29 PM
That still doesn't work. It just sends the domain to http://www.domainname.com, not https://www.domainname.com.

Posted by fabin, 11-15-2011, 11:42 PM
write it above all existing rewrite rules

Posted by n0ts0smart, 11-15-2011, 11:46 PM
I'm still getting the same result. Just sends me to http://www.domain....

Posted by foobic, 11-16-2011, 12:21 AM
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: I'd wonder if mod_rewrite (and / or .htaccess) is actually disabled, except that presumably the site wouldn't work without this rule?



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
How to install CURL? (Views: 797)


Language:

LoadingRetrieving latest tweet...

Back to Top Copyright © 2018 DC International LLC. - All Rights Reserved.