Apache redirect rule optimize
I'm trying to optimize my redirect
RewriteEngine On
RewriteCond %{HTTP_HOST} !^boycottplus\.org$
RewriteRule ^ https://boycottplus.org%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Part 1 is to redirect users that visit the .com site to the .org site
Part 2 is to redirect users that visit unsecure (http) to https
Is there a way to both redirect .com user to the secure .org site, and redirect http users on the .org site to the https site? Both while k开发者_C百科eeping the {request_uri} intact?
Use both conditions in one rule while applying OR logic instead of default AND:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^boycottplus\.org$ [OR]
RewriteCond %{HTTPS} =off
RewriteRule ^ https://boycottplus.org%{REQUEST_URI} [L,R=301]
精彩评论