根文件夹中的 htaccess
#<IfModule mod_rewrite.c>
#RewriteEngine On
#Uncomment these two lines If you want to redirect http to https
#RewriteCond %{HTTPS} off
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php [L]
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^https://3pmix.com/ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
子文件夹中的htaccess
RewriteRule ^classes/.*$ - [F,L]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} config.php|db.php|functions.php [NC]
RewriteRule .* - [F,L]
通过图像的目录结构
最佳答案
对于您显示的示例,请尝试以下规则文件。另外,请确保在测试 URL 之前清除浏览器缓存。
让您的根 htaccess 规则文件如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^3pmix\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
</IfModule>
并让您的子目录 htaccess 规则文件如下:
RewriteOptions InheritBefore
RewriteEngine ON
RewriteRule ^classes - [NC,F,L]
RewriteRule (?:config\.php|db\.php|functions\.php) - [NC,F,L]
我还在您的 htaccess 文件中修复了标志和正则表达式。
关于.htaccess - 将 http 重定向到 https 在子目录中出现问题 404 - 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66928641/