Welcome Guest, Not a member yet? Register   Sign In
For HTTPS CI website - modify htaccess to pull images and files securely
#1

[eluser]novice32[/eluser]
Hello, I am using the below in my htaccess file. I recently enabled HTTPS for the site; however, browsers are now throwing security warnings for unsecured items, such as images, js file, css, etc.

How can I change my htaccess to fetch the below securely whenever someone is accessing the site via HTTPS?

RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|js|stylesheets|scripts|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
#2

[eluser]skunkbad[/eluser]
You don't change your .htaccess. You change the img tag, link tag, etc. If you use relative paths to your resources, they will automatically be secure when in a secure environment. If you look at Community Auth, you'll see I have a modified URL and HTML helper to accmodate for HTTPS. It is one thing I think CodeIgniter could improve on.
#3

[eluser]novice32[/eluser]
Thanks Skunkbad.

I am, however, using relative paths. So, I'm not sure why it doesn't load. That's why I thought maybe it was related to the htaccess file. Here is a snippet from my template layout:

Code:
<head>
....
[removed][removed]
[removed][removed]
<?php echo link_tag('assets/css/style.css') . "\n"; ?>
....
</head>
...
<?php echo img('images/logo.png'); ?>
#4

[eluser]novice32[/eluser]
I should note i'm using CI 1.7.2
#5

[eluser]skunkbad[/eluser]
If you take a look at the html helper, you will see that it does not create HTTPS type img tags or link tags. You'll need to extend the helper if you want to use it for HTTPS. What I was talking about was hand coding the img or link tags, not using the helper.
#6

[eluser]novice32[/eluser]
Got it - thanks!




Theme © iAndrew 2016 - Forum software by © MyBB