仅将一个文件夹重定向到HTTPS,将所有其他文件重定向到HTTP [英] Redirect only one folder to HTTPS, all others to HTTP

查看:155
本文介绍了仅将一个文件夹重定向到HTTPS,将所有其他文件重定向到HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提前道歉,因为在SO上已经多次回答了问题,但是我无法修改任何适合这种情况的答案。

I apologize in advance for asking something that's been answered several times on SO, but I haven't been able to modify any of the answers to work for this case.

我有一个/ secure /文件夹,我需要重定向到HTTPS。应该将该文件夹之外的所有内容重定向到HTTP。

I have a /secure/ folder that I need to redirect to HTTPS. Everything outside of that folder should be redirected to HTTP.

我打算使用绝对链接在我的网站上导航,但我需要保证/ secure中的页面/文件夹只能通过HTTPS查看。对于其他页面并不重要,但我更喜欢它们只能在HTTP上查看,因为我在共享主机上,服务器已经很慢了。

I plan on using absolute links for navigation through my site, but I need to guarantee that the pages in the /secure/ folder are only viewable over HTTPS. For the other pages it doesn't really matter, but I'd prefer them only viewable over HTTP because I'm on shared hosting and the server is already slow as it is.

非常感谢!

推荐答案

在此页面上修改了一个示例此页面。看看以下是否适合您。

Adapted an example on this page this page. See if the following works for you.

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} secure 
RewriteRule ^(.*)$ https://www.example.com/secure/$1 [R,L]

这篇关于仅将一个文件夹重定向到HTTPS,将所有其他文件重定向到HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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