【发布时间】:2014-01-16 08:54:16
【问题描述】:
我的 htaccess 是这样的
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]
之后我再次测试了网址 http://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/
【问题讨论】:
标签: apache .htaccess mod-rewrite redirect