使用 .htaccess 的 http 到 https 重定向不起作用 [英] http to https redirection using .htaccess not working

查看:26
本文介绍了使用 .htaccess 的 http 到 https 重定向不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 http://myip/admin 重定向到 https://myip/admin.我正在尝试使用 .htaccess 来执行此操作(仅对 admin 文件夹进行此操作).

放在相关文件夹中的.htaccess的内容:

<前>重写引擎开启RewriteCond %{HTTPS} !on重写规则 (.*) https://%{HTTP_HOST}%{REQUEST_URI}

(启用 apache mod_rewrite).http://myip/adminhttps://myip/admin 可见(但重定向不起作用).服务器是 Ubuntu.

我从互联网上尝试了上述规则的一些变体,但没有成功:(

任何输入将不胜感激.

问候,日文

解决方案

解决了它并学到了一些新东西.apache 主配置文件中的 AllowOverride 选项设置不正确.

另外,如果有人面临这样的问题 2 点:1) apache 重新加载有时可能无法按预期工作.尝试重启2) 清除浏览器缓存和/或刷新页面.

I want to redirect http://myip/admin to https://myip/admin. I am trying to use .htaccess to do this (want this only for the admin folder).

Contents of .htaccess placed in the relevant folder:


RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

(apache mod_rewrite is enabled). Both http://myip/admin and https://myip/admin are visible (but the redirection does not work). Server is Ubuntu.

I have tried few variations of the above rules from the internet but no luck :(

Any inputs would be appreciated.

regards, JP

解决方案

Solved it and learnt something new. The AllowOverride option in apache's main config file was not set correctly.

Also, if someone faces such issues 2 points: 1) apache reload may sometime not work as expected. Try restart 2) Clear browser cache and / or refresh page.

这篇关于使用 .htaccess 的 http 到 https 重定向不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆