CodeIgniter Forums
.htaccess rewrite https on a specific URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: .htaccess rewrite https on a specific URL (/showthread.php?tid=42702)



.htaccess rewrite https on a specific URL - El Forum - 06-16-2011

[eluser]Mat Marlow[/eluser]
Hi,
I'm posting this in CI forum because I'm wondering if the CI htaccess file is causing me problems.

I'm trying to use a RewriteRule to set https for a certain path in my site ('offers'), and also turn it off for all other pages in my site.

The business part of my .htaccess file:
<code>
...
RewriteCond %{HTTPS} off
RewriteRule offers https://%{HTTP_HOST}%{REQUEST_URI} [L]

RewriteCond %{HTTPS} on
RewriteRule !offers https://%{HTTP_HOST}%{REQUEST_URI} [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
...
</code>

I can get the first rule to turn on https no problem, but when I add the second rule, it will turn of http for everything, but not turn it on for 'offers'.

Ideas anyone?

Thanks,
Mat