Apache rewrite rule to remove index.php and direct certain areas to https

Posted by Stephen Martin on Super User See other posts from Super User or by Stephen Martin
Published on 2012-10-28T16:50:27Z Indexed on 2012/10/28 17:04 UTC
Read the original article Hit count: 251

Filed under:
|

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.

© Super User or respective owner

Related posts about apache

Related posts about mod-rewrite