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

迁移主机后WordPress网站异常求助(含.htaccess重写配置说明)

Hey there, let’s walk through troubleshooting your post-migration issues step by step—your setup (WP in /site subdirectory, root domain access, WP Fastest Cache, and custom /labs rewrite rules) has a few moving parts, so we’ll tackle each one systematically.

1. First: Validate Core WordPress & Directory Configs

These are the most common pain points after migration:

  • Double-check Site URL settings:
    Head to WP Admin > Settings > General. Ensure:
    • WordPress Address (URL): https://example.com/site
    • Site Address (URL): https://example.com
      If you can’t access the admin, add these lines to your wp-config.php file (in the /site directory) to force the correct values:
    define('WP_HOME','https://example.com');
    define('WP_SITEURL','https://example.com/site');
    
  • Audit .htaccess files across directories:
    • Root directory .htaccess: Make sure it forwards non-/labs traffic to the /site subdirectory without breaking your custom rules. Example:
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ - [L]
      
      # Skip /labs directory from WP forwarding
      RewriteCond %{REQUEST_URI} !^/labs/
      # Forward all other non-file/non-directory requests to WP
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /site/index.php [L]
      </IfModule>
      
    • /site directory .htaccess: Keep the default WordPress rewrite rules, and ensure they don’t conflict with WP Fastest Cache later:
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /site/
      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /site/index.php [L]
      </IfModule>
      
    • /labs directory .htaccess: Confirm your custom rules are intact and take priority. Add RewriteBase /labs/ to ensure the rules apply correctly to that subdirectory.
2. Fix WP Fastest Cache Post-Migration Glitches

Cache plugins often hold onto old host paths or settings—let’s reset this:

  • Purge all cached content: Go to WP Admin > WP Fastest Cache, click Delete Cache and Delete Minified CSS/JS to wipe all old cached files from the new server.
  • Temporarily disable the plugin: If the site works with WP Fastest Cache off, the issue is a misconfiguration. Re-enable it and:
    • Add /labs/ to the Exclude list under Cache Settings to avoid caching that directory.
    • For Apache hosts, ensure the Rewrite Rules toggle is on; for Nginx hosts, copy the plugin-generated Nginx rules into your server’s config file (check your host’s docs for where to place this).
  • Check file permissions: Make sure the /site/wp-content/cache directory has proper read/write permissions for the server user—set directories to 755 and files to 644 if needed.
3. Server-Level Checks for the New Host
  • Verify SSL coverage: Ensure your SSL certificate is valid for example.com and all subdirectories. Visit both https://example.com and https://example.com/labs to confirm no certificate errors appear in the browser.
  • Enable required modules: For Apache hosts, confirm mod_rewrite is enabled. For Nginx hosts, double-check that your server config has location blocks handling both WordPress and /labs traffic correctly.
  • Match PHP environment: Ensure the new host’s PHP version is compatible with your WordPress version (minimum 7.4 recommended). Use WP Admin > Tools > Site Health to check for missing extensions (like mysqli or curl) that might cause errors.
4. Test Edge Cases to Pinpoint Issues
  • Test /labs direct access: Visit https://example.com/labs—if it redirects to a WordPress 404, your root .htaccess rule isn’t excluding /labs properly. Double-check the RewriteCond %{REQUEST_URI} !^/labs/ line for typos.
  • Refresh permalinks: Go to WP Admin > Settings > Permalinks and click Save Changes (no need to edit anything). This refreshes WordPress rewrite rules, which often fixes broken post/page links after migration.
  • Test admin access: Visit https://example.com/site/wp-admin—if you can’t log in, clear your browser cache/cookies, or temporarily disable WP Fastest Cache to rule out cache interference.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 09:29:48