http to https redirection using .htaccess not working

烂漫一生 提交于 2021-02-08 07:00:59

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/3869249/http-to-https-redirection-using-htaccess-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!