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

WordPress页面无法重定向至HTTPS问题排查求助

Fixing WordPress HTTPS Auto-Redirect Issue

Let’s work through getting your site to automatically redirect to HTTPS—here’s what you need to do:

1. Fix Your .htaccess Redirect Rules

Your current .htaccess snippet cuts off, so let’s replace it with a complete, working rule that prioritizes HTTPS before WordPress’s default rewrites. Here’s the corrected full content:

# Force HTTPS Redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
  • The R=301 flag sets a permanent redirect, which is better for SEO and ensures browsers remember to use HTTPS going forward.
  • Placing the HTTPS redirect block before the WordPress rules ensures it runs first, so the redirect happens before WordPress processes the request.

2. Strengthen Your wp-config.php Settings

You already have the core HTTPS definitions in place, but adding a couple more lines will handle edge cases (like if your server uses a reverse proxy or load balancer):

Add these right after your existing wp-config.php lines:

define('FORCE_SSL_LOGIN', true);
// Fix HTTPS detection for reverse proxies/load balancers
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
    $_SERVER['HTTPS'] = 'on';
}
  • FORCE_SSL_LOGIN ensures your login page also forces HTTPS, closing a potential security gap.
  • The conditional fixes scenarios where your server might not properly tell WordPress that the connection is HTTPS (common with hosting using proxies).

3. Clear All Caches

This is often the missing step! Be sure to clear:

  • WordPress plugin caches (like WP Rocket, W3 Total Cache, or your theme’s built-in cache)
  • Server-side caches (check your hosting control panel for options like Apache/Nginx cache)
  • Your browser cache (do a hard refresh with Ctrl+Shift+R on Windows/Linux or Cmd+Shift+R on Mac)

Old cached HTTP pages might still load even after you update your settings.

4. Double-Check Server Configuration

  • Confirm that mod_rewrite is enabled on your Apache server (most hosts have this turned on by default, but you can verify via phpinfo() or your hosting dashboard).
  • If you’re using Nginx instead of Apache, the redirect rule will look different—just let me know and I can share the correct Nginx config snippet.

After making these changes, test by visiting the HTTP version of your site (http://webwisemedia.co.uk) — it should automatically jump to the HTTPS version.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:17:10