.htaccess将https重定向到http,除了一个页面和www一起重定向到非www

.htaccess将https重定向到http,除了一个页面和www一起重定向到非www,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,在我的一个域上,我正在使用htaccess RewriteCond %{SERVER_PORT} ^443$ [OR] RewriteCond %{HTTPS} on [OR] RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule (.*) http://example.com/$1 [R=301,L] 将所有https重定向到http以及将www重定向到非www域 现在,我希望secure.php页面使用https协议,

在我的一个域上,我正在使用htaccess

RewriteCond %{SERVER_PORT} ^443$  [OR]
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L] 
将所有https重定向到http以及将www重定向到非www域

现在,我希望secure.php页面使用https协议,而不是http协议,并将www重定向到非www

我可以用下面的几行来实现这个

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteCond %{SCRIPT_FILENAME} \/secure\.php [NC]
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{SCRIPT_FILENAME} !\/secure\.php [NC]
RewriteRule (.*) http://%{HTTP_HOST}/$1 [R=301,L] 
在我的第一个htaccess中,如果用户访问,那么in重定向到in-single重定向

在修改SeaCur.PHP页面之后,在第二个HTTAccess中考虑用户访问->重定向到->重定向到的情况。 这里有两个重定向

请建议我如何使用[OR]加入我的第一个htaccess标准,而不是在所有情况下使用atmost one重定向到达最终页面。

尝试:

RewriteCond %{REQUEST_URI} !^/secure\.php
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L] 

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(secure\.php.*) https://example.com/$1 [R=301,L]