<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ssl &#8211; 科技改变生活-雨落星辰</title>
	<atom:link href="https://p1e.cn/html/tag/ssl/feed" rel="self" type="application/rss+xml" />
	<link>https://p1e.cn</link>
	<description>所有的伟大,都源于一个勇敢的开始</description>
	<lastBuildDate>Thu, 27 Jan 2022 06:38:05 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>宝塔面板开启SSL强制跳转后实现指定目录不跳转HTTPS</title>
		<link>https://p1e.cn/html/3162.html</link>
					<comments>https://p1e.cn/html/3162.html#respond</comments>
		
		<dc:creator><![CDATA[Naoki]]></dc:creator>
		<pubDate>Thu, 27 Jan 2022 01:00:01 +0000</pubDate>
				<category><![CDATA[运维笔记]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[宝塔]]></category>
		<guid isPermaLink="false">https://www.815494.com/?p=3162</guid>

					<description><![CDATA[虽然使用加密连接https更加安全，但在一些特定情况下却只能使用http不能使用加密连接； 在宝塔面板中开启SSL强制跳转后全站所有目录都会跳转到https并没有例外的选项； 本来以为加一条if指定条件不跳转就行了，结果不能实现，原来Nginx不支持if逻辑和嵌套语法； 最后找了不少资料，终于可以实现开启强制跳转后指定目录不跳转https的方案了； 方案 宝塔面板开启强制跳转https后Nginx的配置文件是如下代码； if ($server_port !~ 443){ rewrite ^(/.*)$ https:]]></description>
										<content:encoded><![CDATA[<p>虽然使用加密连接https更加安全，但在一些特定情况下却只能使用http不能使用加密连接；<br />
在宝塔面板中开启SSL强制跳转后全站所有目录都会跳转到https并没有例外的选项；<br />
本来以为加一条if指定条件不跳转就行了，结果不能实现，原来Nginx不支持if逻辑和嵌套语法；<br />
最后找了不少资料，终于可以实现开启强制跳转后指定目录不跳转https的方案了；</p>
<div data-unique="方案"></div>
<h2>方案</h2>
<p>宝塔面板开启强制跳转https后Nginx的配置文件是如下代码；</p>
<pre>
if ($server_port !~ 443){
   rewrite ^(/.*)$ https://$host$1 permanent;
    }
</pre>
<p>然后我们在网站-设置-配置文件中用以下代码替换掉上面的代码即可；</p>
<pre>
    set $flag 0;
    if ($server_port !~ 443) {
        set $flag "${flag}1";
    }
    if ($request_uri !~ "/AAA"){
        set $flag "${flag}2";
    }
    if ($flag = "012"){
         rewrite ^(.*)$  https://$host$1 permanent;
    }
</pre>
<p>条件解释：满足非443端口并且域名目录非/AAA时跳转，包含/AAA目录不跳转；</p>
<div data-unique="说明"></div>
<h2>说明</h2>
<p>我们指定不跳转的目录是/AAA但如果有同名目录，比如/AAAA同样也不会跳转；</p>
<div></div>]]></content:encoded>
					
					<wfw:commentRss>https://p1e.cn/html/3162.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
