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

本地环境WordPress导航菜单失效及分页404问题求助

I’ve tackled quite a few similar WordPress local dev 404 issues before—let’s walk through practical steps to get your site back on track:

  • Verify your local server’s rewrite module is enabled
    WordPress pretty permalinks rely on URL rewriting, which is often disabled by default in local environments.

    • For Apache: Check your httpd.conf file to ensure LoadModule rewrite_module modules/mod_rewrite.so isn’t commented out. Also, make sure your site’s virtual host config has AllowOverride All set (instead of None) so .htaccess rules are applied.
    • For Nginx: Add or confirm this rule in your site’s config file to handle WordPress permalinks:
      location / {
          try_files $uri $uri/ /index.php?$args;
      }
      

    Don’t forget to restart your server after making these changes.

  • Resave your permalink settings (twice!)
    Sometimes a single resave doesn’t properly regenerate rewrite rules. Head to WP Admin → Settings → Permalinks:

    1. Switch to a different permalink structure (e.g., from "Post name" to "Day and name") and save.
    2. Switch back to your original preferred structure and save again.
      This forces WordPress to rewrite the .htaccess (Apache) or trigger Nginx rule recognition.
  • Check your .htaccess file (Apache only)
    Ensure the .htaccess file exists in your site’s root directory and has the correct WordPress rewrite rules. If it’s missing, create it and paste this:

    # 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
    

    Make sure the file has proper read/write permissions for your local server.

  • Confirm your site URL settings are correct
    Go to WP Admin → Settings → General and double-check that both "WordPress Address (URL)" and "Site Address (URL)" match your local development URL (e.g., http://localhost/your-site or http://your-local-site.test). Mismatched URLs often break permalink routing.

  • Disable plugins to rule out conflicts
    SEO, caching, or custom post type plugins can sometimes interfere with rewrite rules. Disable all plugins, then test your navigation links. If they work, re-enable plugins one by one to find the culprit.

  • Switch to a default theme
    Custom themes may have faulty rewrite rules or broken template logic. Switch to a default theme like Twenty Twenty-Four and test. If the 404s go away, you’ll need to debug your theme’s functions.php file (look for custom rewrite rules) or check how it generates navigation links.

If none of these steps work, check your local server’s error logs—they’ll often give specific clues about what’s blocking the rewrite rules.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 08:17:31