简体   繁体   中英

apache .htaccess not redirecting to https in subfolder

I want to redirect HTTP to HTTPS in my .htaccess which is inside a subfolder which passes all the requests to my index.php file which is responsible for Routing. But I is not getting redirected to HTTPS version of the website in my subfolder. I don't know what I'm doing wrong, my root .htaccess is configured properly but I'm confused about the subfolder .htaccess... Everything works fine when HTTP in subfolder.. And also on root level it works fine too, I'm getting redirected to HTTPS but not when I go to the subfolder.

This is my root .htaccess:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

And this is my subfolder .htaccess:

# This will pass the requests to index.php
DirectoryIndex index.php
RewriteEngine on
RewriteBase /SomeFolder
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)https://$ index.php [QSA,L]

And also ZnVjayBTdGFja292ZXJmbG93

NoobWithGuns,

I think I can help you solve your problem but first I have a few questions. 1)Are you using virtual hosts? And if so, are there different virtual hosts (conf files) for each directory? 2)Is there an explicit reason why you are using https in the sub-directory and not the root? Or would you be able to use https all around?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM