Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.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 在单个页面上强制使用https,然后将其他请求重定向到http_Php_Html_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 在单个页面上强制使用https,然后将其他请求重定向到http

Php 在单个页面上强制使用https,然后将其他请求重定向到http,php,html,apache,.htaccess,mod-rewrite,Php,Html,Apache,.htaccess,Mod Rewrite,你好,所以基本上我有一个页面,我想有https,我希望它的孩子和兄弟姐妹有http只 我有一些工作的代码,但是如果我点击一个从ssl页面到非ssl页面的链接,https仍然保留,我试图让它重定向回http 这是我到目前为止所拥有的 RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] RewriteCon

你好,所以基本上我有一个页面,我想有https,我希望它的孩子和兄弟姐妹有http只

我有一些工作的代码,但是如果我点击一个从ssl页面到非ssl页面的链接,https仍然保留,我试图让它重定向回http

这是我到目前为止所拥有的

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R=301]

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^prepaid/?$ https://www.domain.com/prepaid/ [R=301,L]

RewriteRule ^prepaid/h2o/?$  index.php?p=prepaid&s=h2o [L]
RewriteRule ^prepaid/?$      index.php?p=prepaid       [L]
主要目标是在任何时候强制www以及后续的斜杠 还希望仅在上强制使用https,然后在我试图强制使用http的任何Children或sibliligs上强制使用https。即使您在https页面上,并单击“离开”(这是我一直坚持的内容,它当前仍保持在https中)

尝试以下方法:

<Location /sample.php>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Location>

重新启动发动机
重写条件%{HTTPS}关闭
重写规则(*)https://%{HTTP\u HOST}%{REQUEST\u URI}

将sample.php重命名为您的文件名

这不起作用,该文件是一个常见的模板get文件(index.php),页面不同于get变量(index.php?p=preadward)将sample.php替换为index.php?p=preadward我希望它能起作用。您真的应该将链接更新为完整路径,即specfiy
http://example.com/foo.html
,与foo.html不同的是,这种方式除了在一个页面上强制使用ssh之外无需做任何事情,这是一个RewriteCond/RewriteRule组合。