.htaccess 将子文件夹重定向到 HTTPS

编程入门 行业动态 更新时间:2024-10-20 13:45:58
本文介绍了.htaccess 将子文件夹重定向到 HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试为我的 .htaccess 文件编写 RewriteRule.具体来说,每当用户访问特定的子目录时,我希望它重写以强制进行 HTTPS 连接.

I'm trying to write a RewriteRule for my .htaccess file. Specifically, whenever a user accesses a specific subdirectory, I would like it to Rewrite to force an HTTPS connection.

例如,每当有人访问:www.mydomain/subdirectory(以及该子目录"的任何其他子目录).

For example, whenever someone accesses: www.mydomain/subdirectory (and any other sub-directories of that "subdirectory").

我希望它重写为 www.mydomain/subdirectory

我尝试了以下方法,但它似乎创建了一个循环:

I've tried the following, but it appears to create a loop:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ www.mydomain/subdirectory/$1 [R=301,L]

此外,此 .htaccess 文件位于我的域的根目录中.

Also, this .htaccess file is placed in the root of my domain.

关于如何修改我的 RewriteRule 的任何想法?

Any ideas on how to modify my RewriteRule?

非常感谢!

推荐答案

我会把它放到域的根目录中:

I would put this into the domain's root directory:

RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(subdirectory/.*)$ www.mydomain/$1 [R=301,L]

更多推荐

.htaccess 将子文件夹重定向到 HTTPS

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

发布评论

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

>www.elefans.com

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