【发布时间】:2022-01-07 03:17:00
【问题描述】:
我正在使用 WordPress,我们有一个不是 WordPress 目录 /images 的目录,我们需要此目录为 HTTP,只有其他所有内容都应强制为 HTTPS。
在 WordPress 设置中,我们将域设置为 HTTP
在.htaccess 文件中,我们有以下内容。
我似乎无法让它工作。我们的主机是 cloudways,如果这有帮助的话
# This file was updated by Duplicator on 2018-09-10 16:52:27. See .htaccess.orig for the original .htaccess file.
# Please note that other plugins and resources write to this file. If the time-stamp above is different
# than the current time-stamp on the file system then another resource has updated this file.
# Duplicator only writes to this file once during the install process while running the installer.php file.
#RewriteEngine On
#RewriteCond %{HTTP:X-Forwarded-SSL} !on
#RewriteCond %{REQUEST_URI} ^\/(images)
#RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
#RewriteCond %{HTTP:X-Forwarded-SSL} =on
#RewriteCond %{REQUEST_URI} !^\/(images)
#RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# MalCare WAF
<Files ".user.ini">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
# END MalCare WAF
【问题讨论】:
-
"not a wordpress directory /images" - 当您说它“不是 WordPress 目录”时,我认为您的 WordPress 网站没有以任何方式使用它? IE。您的页面都没有引用
/images子目录中的图像?不确定为什么您似乎试图在您发布的两条规则中从 HTTPS 重定向回 HTTP?我以为你想强制 HTTPS,除了特定的子目录?
标签: wordpress .htaccess mod-rewrite https url-rewriting