SSL 重写重定向 apache2
我有两个虚拟主机设置为服务器上的同一目录。一个监听端口 80,另一个监听 443。
我有 3 个文件,
index.html
secure.html
view.html
每个文件都有一个菜单:
<ul>
<li><a href="index.html">Index</a></li>
<li><a href="secure.html">secure</a></li>
<li><a href="view.html">view</a></li>
</ul>
我想设置重定向,使其满足以下条件:
http://localhost/secure.html - 转到 https://localhost/secure.html
http://localhost/index.html - 转到 http://localhost/index.html
http:// localhost/view.html - 转到 http://localhost/view.html
https://localhost/index.html - 转到 http://localhost/index.html
https://localhost/view.html - 转到 http://localhost/view.html
当我进入时
https://localhost/secure.html 然后我点击
Index 将我带到 < a href="http://localhost/index.html" rel="nofollow">http://localhost/index.html
查看 将我带到 http://localhost/view.html
我怎样才能实现这一目标?
我知道我必须将这些放入 .htaccess 文件中,但我不知道如何定义这些配置,
I have two virtual hosts set to the same directory on the server. One listens on port 80 and the other on 443.
I have 3 files
index.html
secure.html
view.html
Each file has a menu:
<ul>
<li><a href="index.html">Index</a></li>
<li><a href="secure.html">secure</a></li>
<li><a href="view.html">view</a></li>
</ul>
I would like to set redirecting so it meets these conditions:
http://localhost/secure.html - goes to https://localhost/secure.html
http://localhost/index.html - goes to http://localhost/index.html
http://localhost/view.html - goes to http://localhost/view.html
https://localhost/index.html - goes to http://localhost/index.html
https://localhost/view.html - goes to http://localhost/view.html
and when I'm in
https://localhost/secure.html and I click on
Index takes me to http://localhost/index.html
View takes me to http://localhost/view.html
How could I achieve this?
I know I have to put these in .htaccess file but I don't know how to define these confitions,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这两个规则:
如果您有多个文件,只需扩展
^/(secure\.html|...)$
等模式。Try these two rules:
If you have more than this single file, just extend the pattern like
^/(secure\.html|…)$
.