http到https重定向登录页面

时间:2012-11-12 06:26:11

标签: apache mod-rewrite redirect

我想在访问“登录”页面时将我的应用程序的用户重定向到HTTPS协议。网址是实物:

http://localhost/default/Login

我在我的apache conf文件中写了下面的重写规则(请注意我只想从conf文件中执行此操作而不是从.htaccess执行此操作)

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^/Login$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

此重定向无效,我无法找出原因。还尝试过打印重写日志,但也无法从中进行调试。

请让我知道我做错了什么。

2 个答案:

答案 0 :(得分:0)

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} Login [NC]
RewriteRule $ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]

这个规则解决了我的问题。发现^是开始使用网址的。

答案 1 :(得分:-1)

尝试将以下代码添加到httpd.conf文件中。

Redirect permanent / https://localhost/default/Login

有关完整说明,请参阅Link

相关问题