Google Cloud Platform上OpenLiteSpeed部署的WordPress站点HTTP与HTTPS内容不一致及重写规则异常问题求助
Troubleshooting & Fixes for Your OpenLiteSpeed + WordPress Setup
Let’s work through your issues step by step—we’ll fix the WebAdmin rewrite rule save error, resolve the HTTP/HTTPS content mismatch, and get your domain redirecting properly.
1. Fix the WebAdmin Rewrite Rule Save 404 Error
First, let’s unblock the WebAdmin console since it’s preventing you from setting up redirects directly. Try these common fixes:
- Check Firewall & WebAdmin Listener: Confirm the OpenLiteSpeed WebAdmin port (default 7080) is allowed in your GCP firewall rules. Also, log into the WebAdmin (if you can access it) and go to
Server Configuration > Listenersto verify the WebAdmin listener is active with the correct IP/port. - Reset WebAdmin Credentials: Permission glitches can cause this. Run this command to reset your WebAdmin password, then log back in:
/usr/local/lsws/admin/misc/admpass.sh - Fix Directory Permissions: Ensure the WebAdmin files have the right ownership:
chown -R lsadm:lsadm /usr/local/lsws/admin/
After trying these, you should be able to save rewrite rules without hitting a 404.
2. Resolve Inconsistent HTTP/HTTPS Content
The content mismatch almost always happens because WordPress isn’t using HTTPS as its canonical URL. Here’s how to fix it:
- Update WordPress Site URLs: Log into your WordPress admin (use HTTPS if possible, or phpMyAdmin if HTTPS admin is broken). Go to
Settings > Generaland set both WordPress Address (URL) and Site Address (URL) tohttps://bonheurgifts.in/. - Flush Caching Layers: Since you’re using Redis and Memcached, old HTTP-based content might be stuck in cache. Run these commands to clear them:
# Flush Redis cache redis-cli FLUSHALL # Restart Memcached to clear its cache sudo systemctl restart memcached - Update Existing Content Links: If old HTTP links are still in your posts/pages, use WP CLI to replace them (run this from your WordPress root directory, e.g.,
/var/www/html):
If you don’t have WP CLI installed, use phpMyAdmin to run this SQL query:cd /var/www/html wp search-replace 'http://bonheurgifts.in' 'https://bonheurgifts.in' --skip-columns=guidUPDATE wp_posts SET post_content = REPLACE(post_content, 'http://bonheurgifts.in', 'https://bonheurgifts.in');
3. Set Up Automatic Redirects (HTTP → HTTPS)
Now that WebAdmin is working, set up rewrite rules to redirect all traffic to HTTPS:
- Log into OpenLiteSpeed WebAdmin (port 7080).
- Go to
Virtual Hosts > Your WordPress VHost > Rewrite. - Toggle Rewrite to
Yes, then paste these rules into the Rewrite Rules box:RewriteEngine On # Redirect all HTTP traffic to HTTPS RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] - Save the settings, then click Graceful Restart in the top-right corner of the WebAdmin to apply changes.
- Add redundancy to your WordPress
.htaccessfile (in your WP root directory):<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Keep WordPress default rewrite rules below RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
4. Verify the Fixes
- Open an incognito window and visit
http://bonheurgifts.in—it should automatically redirect tohttps://bonheurgifts.in. - Check that both HTTP and HTTPS versions now show identical content.
- Test saving a rewrite rule in WebAdmin again to confirm the 404 error is resolved.
内容的提问来源于stack exchange,提问作者Suyash Nalawade
相关产品推荐
相关产品推荐

