Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Htaccess-HTTPS重定向_Php_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Php Htaccess-HTTPS重定向

Php Htaccess-HTTPS重定向,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,我试图让我的.htaccess文件只将某些页面/文件夹重定向到https,如果它不是需要加密的页面,那么它应该向用户发送http页面。此外,我想能够列出某些文件夹,可以是HTTP或HTTPS 下面是我自己写的东西。但似乎并不完全正确 <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{SERVER_PORT} 80 RewriteCond $1 ^(myaccount|payment\.html

我试图让我的.htaccess文件只将某些页面/文件夹重定向到https,如果它不是需要加密的页面,那么它应该向用户发送http页面。此外,我想能够列出某些文件夹,可以是HTTP或HTTPS

下面是我自己写的东西。但似乎并不完全正确

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

重新启动发动机
重写基/
重写cond%{SERVER_PORT}80
重写第二个$1^(myaccount | payment\.html)
重写规则^(.*)$https://www.domain.com/$1[R=301,L]
重写cond%{SERVER_PORT}443
1美元^(myaccount | payment\.html)
重写规则^(.*)$http://www.domain.com/$1[R=301,L]

您正在检查重写模式中的文本
$1
。应该是:

RewriteCond %{REQUEST_URI} ...stuff to match against here...

您正在RewriteCond模式中检查文本
$1
。应该是:

RewriteCond %{REQUEST_URI} ...stuff to match against here...

这应该是你想要的

RewriteCond %{SERVER_PORT} 443 [NC]
RewriteCond %{REQUEST_URI} !^/(myaccount|payment)\.html [NC]
RewriteRule . http://www.domain.com/%{REQUEST_URI}/ [R=301,L]

这应该是你想要的

RewriteCond %{SERVER_PORT} 443 [NC]
RewriteCond %{REQUEST_URI} !^/(myaccount|payment)\.html [NC]
RewriteRule . http://www.domain.com/%{REQUEST_URI}/ [R=301,L]