.htaccess redirect subfolder to HTTPS

前端 未结 7 1838
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 01:41

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 connec

7条回答
  •  没有蜡笔的小新
    2020-12-14 02:37

    Ahh, its a combo of the two. MonoMano - you've omitted the subdirectory in the first part of the RewriteRule, therefore directing ALL traffic to the HTTPS subdomain address. I found that checking for 'off' was more reliable than checking for !=on, dont ask me why!

    You'd want to add the subdirectory back in as per Floern's response, see below:

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

提交回复
热议问题