Reputation: 39
I use .htaccess
to redirect the pages to HTTP and not to HTTPS.
The code is :
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Now, I want all pages other than the index to redirect to HTTPS.
All except index.html
.
How can i do this with .htaccess
?
Upvotes: 1
Views: 48
Reputation: 1201
Try something like this:
# Redirect all pages, except homepage to HTTPS
RewriteCond %{HTTPS} off
RewriteRule !^(index\.html)?$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
# Redirect homepage to HTTP
RewriteCond %{HTTPS} on
RewriteRule ^(index\.html)?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
Test with 302 (temporary) redirects to avoid caching issues.
You will need to clear your browser cache before testing.
Upvotes: 1