htaccess的子文件夹重定向到HTTPS文件夹、重定向、htaccess、HTTPS

由网友(情之需者,单身者也。)分享简介:我试图写一个重写规则为我的.htaccess文件。具体而言,当一个用户访问一个特定的子目录中,我想它重写强制HTTPS连接。I'm trying to write a RewriteRule for my .htaccess file. Specifically, whenever a user accesses a...

我试图写一个重写规则为我的.htaccess文件。具体而言,当一个用户访问一个特定的子目录中,我想它重写强制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.

例如,当有人访问: http://www.mydomain.com/subdirectory (和说,子目录其他任何子目录)

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

我想它重写 https://www.mydomain.com/subdirectory

我已经试过以下,但它似乎创建一个循环:

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

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

此外,这个.htaccess文件放置在我的域的根。

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

如何修改我重写规则?任何想法

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/.*)$ https://www.mydomain.com/$1 [R=301,L]
阅读全文

相关推荐

最新文章