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

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

问题描述

我想将 http://myip/admin 重定向到

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).

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

Contents of .htaccess placed in the relevant folder:



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

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

(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 :(

任何输入将不胜感激.

致谢,JP

推荐答案

解决了该问题并学到了一些新知识.apache的主配置文件中的AllowOverride选项未正确设置.

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

此外,如果有人遇到这样的问题,请注意2分:1)apache重新加载有时可能无法正常工作.尝试重新启动2)清除浏览器缓存和/或刷新页面.

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天全站免登陆