将网站从http重定向到https

编程入门 行业动态 更新时间:2024-10-24 18:18:12
本文介绍了将网站从http重定向到https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前正在运行一个以struts编写的网站.我正在使用Apache Web服务器并使用AJP进行代理将我的Web应用程序传递到Apache tomcat服务器.

I am currently running a website written in struts. I am using Apache web server and using AJP to ProxyPass my web application to Apache tomcat server.

我的服务器是Amazon托管的Ubuntu服务器.我能够使用http成功运行我的Web应用程序.

My server is Ubuntu server hosted in Amazon. I was able to run my web application successfully using http.

现在,我正计划为上述Web应用程序实现SSL.我已经完成所有SSL实施步骤,现在可以使用https (即{MY_APPLICATION_URL}

Now I am planning to implement SSL for the above web application. I have completed all the SSL implementation steps and now I can access my web application successfully using https that is, {MY_APPLICATION_URL}

现在问题出在:当用户输入我的应用程序URL(例如{MY_APPLICATION_URL}或{MY_APPLICATION_URL})时,我需要重定向并使其仅使用{MY_APPLICATION_URL}. http访问不能在那里.

Now the issue is with: when user enter my application URL like {MY_APPLICATION_URL} or {MY_APPLICATION_URL}, I need to redirect and make them to only use {MY_APPLICATION_URL}. http access must not be there.

我找到了以下链接: www.sslshopper. com/apache-redirect-http-to-https.html 和已安装重写模块在apache服务器中(通过webmin).然后在我的应用程序的虚拟主机中添加以下几行(编辑指令).

I found the following link: www.sslshopper/apache-redirect-http-to-https.html and installed rewrite module in apache server (through webmin). Then added the following lines in my application's virtual host (Edit directives).

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI}

即使在上述重定向之后,当用户输入{MY_APPLICATION_URL}或{MY_APPLICATION_URL}时,也会显示我的apache服务器的默认欢迎页面.但是,当我输入{MY_APPLICATION_URL}时,我能够成功访问我的Web应用程序.

Even after above redirecting, when user enters {MY_APPLICATION_URL} or {MY_APPLICATION_URL} it displays my apache server's default welcome page. However when I type {MY_APPLICATION_URL}, I was able to access my web application successfully.

任何人都可以指导我做错了什么地方.

Can anyone please guide me where I am doing wrong.

谢谢.

推荐答案

此解决方案对我有帮助.

This solution helped me.

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ domain.name/$1 [R,L] </IfModule>

我希望它也会对您有所帮助.

I hope it'll be helpfull for you too.

更多推荐

将网站从http重定向到https

本文发布于:2023-10-31 15:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546525.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   网站   http   https

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!