开发者

Apache redirect rule optimize

开发者 https://www.devze.com 2023-03-30 04:55 出处:网络
I\'m trying to optimize my redirect RewriteEngine On RewriteCond %{HTTP_HOST} !^boycottplus\\.org$ RewriteRule ^ https://boycottplus.org%{REQUEST_URI} [L,R=301]

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号