You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress指定页面强制HTTPS的.htaccess规则引发404问题求助

Fixing 404 Errors on HTTPS Membership Pages in WordPress (draw Directory)

Looks like the issue comes from a couple of small but critical issues in your .htaccess rules—let's break this down and fix it step by step:

1. Syntax Error in Rewrite Flags

The first problem is the extra space after the comma in your RewriteRule flag: [R=302, L]. Mod_rewrite is strict about flag formatting, and that space causes the rule to be parsed incorrectly. This means your redirect might not be firing properly, or it's conflicting with WordPress's internal routing.

2. Imprecise URI Matching

Your original RewriteCond %{REQUEST_URI} membership works, but since your WordPress is installed in the /draw/ directory, adding a more specific match will prevent accidental redirects and ensure the rule targets exactly your membership pages.

Corrected .htaccess Code

Here's the fixed version of your file with explanations included:

RewriteEngine On

# Redirect to HTTPS only for membership pages in the /draw/ directory
RewriteCond %{HTTPS} off
# Match any URI starting with /draw/membership (add [NC] for case-insensitive matching)
RewriteCond %{REQUEST_URI} ^/draw/membership [NC]
# Fixed flag format (no space after comma)
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
# We already enabled RewriteEngine at the top, so no need to enable it again
RewriteBase /draw/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /draw/index.php [L]
</IfModule>
# END WordPress

Additional Tips

  • If your membership pages have slugs that contain "membership" (e.g., /draw/membership-plans or /draw/premium-membership), replace the URI condition with RewriteCond %{REQUEST_URI} membership [NC] to match any occurrence of the word.
  • Use R=302 for testing to avoid caching issues, then switch to R=301 once you confirm everything works.
  • After updating .htaccess, go to your WordPress admin → Settings → Permalinks and click "Save Changes" without modifying anything. This flushes WordPress's rewrite rules and ensures it recognizes the HTTPS versions of your pages.

内容的提问来源于stack exchange,提问作者user2794858

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:40:48