繁体   English   中英

重定向到https(一个链接除外)

[英]Redirect to https except one link

我使用此代码将所有链接重定向到httpswww

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

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

但是我希望一个链接不重定向到https

范例:

http://myname.com --> https://www.myname.com
http://myname.com/file.php -- > https://www.myanem.com/file.php
http://myname.com/except.php -- > http://www.myanem.com/except.php

在最佳示例中,我希望except.php 重定向到https

应该这样做:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/except\.php$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/except\.php$
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ %{REQUEST_SCHEME}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM