Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
Apache https重定向时htaccess重写规则失败_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Apache https重定向时htaccess重写规则失败

Apache https重定向时htaccess重写规则失败,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我的眼睛看起来像这样 RewriteEngine On RewriteCond %{HTTP_HOST} !^localhost$ RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteRule ^login/?(.

我的眼睛看起来像这样

RewriteEngine On
RewriteCond %{HTTP_HOST} !^localhost$
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^login/?(.*)$ login.php$1 [L]
RewriteRule ^register/?(.*)$ register.php$1 [L]
我想重定向我的页面登录并重定向到https,所以我添加了下面的代码

RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/(login|register)/?$
RewriteRule .*$ http://%{HTTP_HOST}%{REQUEST_URI} [L]
所以当我打字的时候http://www.xyz.com/login/ 它重定向到https://www.xyz.com/login/ 当我决定将未登录或注册的页面重定向到http时,一切都很好

RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/(login|register)/?$
RewriteRule .*$ http://%{HTTP_HOST}%{REQUEST_URI} [L]
之后,我测试了urlhttp://www.xyz.com/login/ 再一次,它将我重定向到https://www.xyz.com/login.php


有没有重定向的想法http://www.xyz.com/login/ 到https://www.xyz.com/login/ 当我点击链接的时候,在那页上https://www.xyz.com/news/1/ 重定向到http://www.xyz.com/news/1/

尝试将此项添加到在线引擎的正下方:


看起来您的规则粘贴错误,两个规则块是相同的。

谢谢您的回答,是的,第三个代码块是错误的。我尝试了你的代码,不幸的是它将我重定向到http://www.xyz.com/**login.php**nothttp://www.xyz.com/login/@ilazmi在将login重写为login.php的2条规则之前,您有过它吗?这应该是你的首要原则
RewriteCond %{HTTPS} off
RewriteRule ^(login|register)(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]

RewriteCond %{HTTPS} on
RewriteRule !^(login|register) http://%{HTTP_HOST}%{REQUEST_URI} [L,R]