.htaccess的HTTPS重定向 [英] Htaccess HTTPS redirection
本文介绍了.htaccess的HTTPS重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让我的.htaccess文件重定向到只有特定的网页/文件夹为https,如果它不是需要加密的页面,那么它应该拍摄用户的HTTP页面。此外,我希望能够将某些文件夹可以是HTTP或HTTPS
下面是我试图用写了我自己。但似乎无法正常工作的所有。
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} SERVER_PORT 80
的RewriteCond $ l ^(我的帐户|支付\ html的)
重写规则^(。*)$ https://www.domain.com/$1 [R = 301,L]
的RewriteCond%{} SERVER_PORT 443
的RewriteCond $ l ^(我的帐户|支付\ html的)!
重写规则^(。*)$ http://www.domain.com/$1 [R = 301,L]
< / IfModule>
解决方案
您正在检查的文字 $ 1
在你的RewriteCond模式。它应该是:
的RewriteCond%{REQUEST_URI} ...的东西来匹配这里...
I'm trying to get my .htaccess file to redirect only certain pages/folders to https and if its not the pages that need to be encrypted then it should shoot the user the the http page. Also I would like to be able to list certain folders that can either be HTTP or HTTPS
Here is what I tried using writing up myself. But seemed to not work all correctly.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteCond $1 ^(myaccount|payment\.html)
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 443
RewriteCond $1 !^(myaccount|payment\.html)
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>
解决方案
You're checking a literal $1
in your RewriteCond patterns. It should be:
RewriteCond %{REQUEST_URI} ...stuff to match against here...
这篇关于.htaccess的HTTPS重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文