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

WordPress子目录部署后线上页面异常,wp-admin报404求助

Hey Adrian, let's work through this step by step—this exact set of issues is super common when moving a local WordPress site to a live host, especially with subdirectory data setups and UK2's specific server configs. Here's how to fix each problem:

1. Fix Site URL Mismatches (Root Cause of Missing Styles)

Your local WAMP setup uses localhost/[your-path] for asset URLs, but your live UK2 site is using your domain. WordPress is still trying to pull CSS/JS from your local server, which is why you only see plain text. Here are two reliable fixes:

  • Option 1: Edit wp-config.php (fastest, no admin access needed)
    Open your root wp-config.php file and add these lines right above the /* That's all, stop editing! Happy publishing. */ comment:
    define('WP_HOME', 'https://yourdomain.com');
    define('WP_SITEURL', 'https://yourdomain.com');
    
    If your WordPress data (wp-content, wp-includes) lives in a subdirectory like /wp-data, adjust WP_SITEURL to https://yourdomain.com/wp-data
  • Option 2: Update via Database (if wp-config tweaks don't stick)
    Use UK2's phpMyAdmin tool to access your WordPress database, find the wp_options table, and update:
    • The siteurl field to your live domain (plus subdirectory path if applicable)
    • The home field to your live domain root
2. Fix .htaccess for Rewrite Rules (Fixes wp-admin 404 & Broken Pages)

UK2's Apache servers often need a specific .htaccess configuration, especially if you're using a subdirectory for data. Replace your root .htaccess file with this (adjust the RewriteBase line if your WordPress core is in a subdirectory):

# 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

If your WordPress core is hosted in a subdirectory like /wp-core, change RewriteBase / to RewriteBase /wp-core/

3. Verify UK2 Server Settings
  • Enable mod_rewrite: UK2 might have this disabled by default. Log into your cPanel, navigate to "Apache Modules" and ensure mod_rewrite is checked. If you don't see this option, shoot UK2 support a quick message—they can enable it for you in minutes.
  • Check File Permissions: Set your wp-content folder to permission 755 and all files inside to 644. UK2's servers are strict about permissions, and incorrect settings can block asset loading entirely.
4. Final Test & Quick Troubleshooting
  • After making these changes, hard-refresh your browser (Ctrl+Shift+R on most browsers) to force fresh asset loading—don't skip this, cached local assets will still break things.
  • If wp-admin still throws a 404, add define('FORCE_SSL_ADMIN', true); to your wp-config.php if you're using HTTPS (most UK2 plans include free SSL now).
  • If you're using a custom data subdirectory (not the default wp-content), double-check that your wp-config.php has the correct definitions for WP_CONTENT_DIR and WP_CONTENT_URL pointing to your live subdirectory path.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 07:34:27