Reputation:
So I want to do the following:
if the user tries to go to an ypart of the site other than index.php, they get redirected to the https version.
so if they try to go to example.com/index.php they do not get redirected to the https version
but if they go to any part of the site other than index.php (like welcome.php) they get redirected to the https version.
here's how I did full site https redirection before (I'm not sure how to do full site redirection to https example on index.php)
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ https://www.handybook.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www.example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
Upvotes: 0
Views: 142
Reputation: 238
In order to have all pages except for index redirect to https, add the following to your .htaccess file:
RewriteCond %{HTTPS} !on
RewriteRule !^(index)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}
You can add additional exceptions using the pipe character within the parenthesis, like so:
RewriteRule !^(index|about|contact)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}
Upvotes: 1