WordPress非Plain固定链接跳转首页问题求助
Hey there, let’s break down how to diagnose and fix this stubborn permalink issue you’re facing. It’s super common after migrations, so let’s take it step by step—always back up your site and database first (Hostinger has a one-click backup tool, use that before any changes!).
First, Use Tools to Diagnose the Redirects
You mentioned wanting plugins/tools to track down why the redirects are happening—here are two reliable options:
- Query Monitor: This plugin lets you dig into every request on your site, including exactly what’s triggering the redirect (whether it’s a plugin, theme function, or database rule). Install it, then visit any page that redirects to home; check the "Redirects" tab to see the source.
- Redirection: Not just for managing redirects, it logs every redirect that happens on your site. After installing, let it run for a few minutes while you test links—you’ll see a log entry for each redirect, showing the original URL, target (home), and what caused it (e.g., "WordPress rewrite rule" or a custom plugin rule).
Check the Low-Hanging Fruit
1. Fix Your .htaccess File
Looking at your current .htaccess, the WordPress rewrite rule section between # BEGIN WordPress and # END WordPress is empty—that’s a big problem! When you set permalinks to anything other than Plain, WordPress needs those core rewrite rules to route URLs correctly.
To fix this:
- Go to your WordPress admin → Settings → Permalinks
- Select your desired permalink structure (e.g., Post name)
- Click Save Changes (even if it’s already selected—this forces WordPress to regenerate and write the correct rules to
.htaccess)
Your WordPress section should now look like this (if it doesn’t, double-check that .htaccess has proper write permissions):
# 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
2. Verify Core Database Settings
Since this happened post-migration, let’s confirm your site URLs are correct in the database:
- Access your Hostinger phpMyAdmin, open your WordPress database
- Look at the
wp_optionstable (prefix might be different if you changed it) - Find the
siteurlandhomerows—both should be set to your full HTTPS URL (e.g.,https://url.com) - If they’re not, edit them to the correct value and save
Dig Deeper Into Database Issues
You checked rewrite_rules, but let’s cover a few other migration-related spots:
Reset Rewrite Rules
Sometimes the wp_rewrite_rules table gets corrupted during migration. Try resetting it:
- Export the
wp_rewrite_rulestable from phpMyAdmin as a backup - Empty the table (select all rows, delete them)
- Go back to Settings → Permalinks in WordPress and save changes—this will regenerate fresh rewrite rules
Check for Migration Residue
From PrestaShop to WooCommerce migrations, sometimes old URLs or metadata get left behind:
- In
wp_posts, check theguidcolumn—while this doesn’t affect front-end permalinks, if a large number are still pointing to old PrestaShop URLs, it could cause conflicts (you can batch update these with a safe SQL query if needed, but only after backing up) - In
wp_postmeta, look for_wp_old_slugentries that might be pointing to invalid paths—delete any that seem unrelated to your current site structure
Hostinger/LiteSpeed Specific Checks
Since you’re on Hostinger with LiteSpeed:
- Clear All Caches: You mentioned clearing cache, but make sure you hit every spot: Hostinger’s site cache, LiteSpeed’s server-level cache, and any CDN cache if you’re using it (Hostinger’s built-in CDN or Cloudflare)
- Wordfence WAF: Your
.htaccesshas Wordfence’s WAF rules—try temporarily disabling Wordfence (or commenting out the WAF lines in.htaccess) to rule out it interfering with rewrite rules
Final Notes
If none of these work, try switching to a default WordPress theme (like Twenty Twenty-Four) temporarily—sometimes custom themes have rewrite rule overrides that cause this issue.
内容的提问来源于stack exchange,提问作者hellokevin

