Reputation: 3642
I have the code:
# No https a https
RewriteCond %{HTTPS} !=on [NC]
RewriteRule !(cecabank)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I want to redirect to https when http is not ON and URL is not cecabank.
This works: http://sample.es/sample redirect 301 to https://sample.es/sample
This doesnt work: http://sample.es/cecabank redirect 301 to http://sample.es/index.php
I don't want redirect to index.php with 301. If I remove the HTTPS redirection works fine but It will not redirect.
Upvotes: 1
Views: 56
Reputation: 80657
Try the following
RewriteEngine On
# No https a https
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !^/cecabank [NC]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L,END]
The END
flag (available since Apache 2.4+) will take care of forced redirection.
Upvotes: 2