Welcome Guest, Not a member yet? Register   Sign In
Hyperlinks automatically changed from HTTP to HTTPS
#1

[eluser]a_bains[/eluser]
Hello,

I have setup SSL encryption on my CodeIgniter website. And on secured pages (HTTPS) every hyperlink changes from HTTP to HTTPS. Does anyone know how to maintain the hyperlinks on the pages as HTTP?

In my view when I hard code the URLs with 'http://' then it doesn't change.. but when its not hard coded just like this '/cart' then HTTPS gets added.

Thanks!
#2

[eluser]WanWizard[/eluser]
If you use relative links, the browser will convert them locally to absolute links, using the current URI as the basis. So if that uses https://, so will the relative link.

Hardcoding is the only alternative, by which I mean "use site_url() for normal links, and create a second one for secure links" (or extend the URL helper and add a parameter to site_url()).
#3

[eluser]a_bains[/eluser]
Ahh I see that makes sense.. thanks Smile

Now, I am trying to switch between HTTPS and HTTP on certain pages such as cart, payment, registration.. I really want to do it with mod_rewrite (.htaccess)

It is working for the most part, but its annoying because it shows index.php on the HTTPS pages!

Here is my .htaccess

Code:
RewriteEngine on

RewriteCond %{SERVER_PORT} 80
RewriteCond $1 ^(index.php/account/register|index.php/cart|index.php/checkout)
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]

RewriteCond %{SERVER_PORT} 443
RewriteCond $1 !^(index.php/account/register|index.php/cart|index.php/checkout)
RewriteRule ^(.*)$ http://mysite.com/$1 [R,L]

RewriteCond $1 !^(index\.php|css|images|scripts|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

I would really appreciate some help .. because I'm so close to getting it. I read this post (http://ellislab.com/forums/viewthread/83154/) and they don't have the index.php prefixed to the URL in the htaccess, but if I remove all the index.php prefixes then the rewrite condition is never met. I appreciate the help !
#4

[eluser]a_bains[/eluser]
Nevermind, problem solved! Referenced this thread: http://ellislab.com/forums/viewthread/86113/

I used the rewrite conditions and rules in that thread.




Theme © iAndrew 2016 - Forum software by © MyBB