Apache rewrite rule to remove index.php and direct certain areas to https
- by Stephen Martin
I have a codeignitor application running on Apache2, I have managed to remove the index.php from the urls with this .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
now I want to make certain parts of the site redirect to https, I tried this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
RewriteRule ^/?cpanel/(.*) https://%{SERVER_NAME}/cpanel/$1 [R,L]
RewriteRule ^/?login/(.*) https://%{SERVER_NAME}/cpanel/$1 [R,L]
But it doesn't work. I have to say when it comes to Apache rewrites im a noob. I can't find any tutorials on how to remove index.php and rewrite/redirect certain parts of the site to https.
Any ideas,
Thanks.