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

将wp-content移至public_html后站点无法加载,提示主题目录错误

Fixing WordPress Theme Directory Error After Moving wp-content to public_html

Hey there, let's troubleshoot this issue step by step—that theme directory error is telling us WordPress can't locate your wp-content folder (and its subfolders like themes) after you moved it to public_html. Here's how to get your site back up and make your media URLs work without the subfolder:

1. Verify Your wp-content Migration First

Before tweaking any code, double-check the basics:

  • Confirm the entire wp-content folder (including themes, plugins, uploads, and all their files) is fully copied into your public_html directory—don't skip any subfolders or hidden files.
  • Check folder permissions: Set wp-content and all its subfolders to 755, and individual files to 644. Incorrect permissions often block WordPress from reading these directories.

2. Correct Your wp-config.php Configuration

It sounds like your initial config was off. Add these lines before the /* That's all, stop editing! Happy publishing. */ line in your wp-config.php (located in your WordPress subfolder):

// Absolute server path to your wp-content folder in public_html
define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content');

// Public URL for wp-content (no subfolder here since it's in public_html root)
define('WP_CONTENT_URL', 'https://yourdomain.com/wp-content');

// Optional: Explicitly define plugin paths to avoid issues
define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins');

If $_SERVER['DOCUMENT_ROOT'] doesn't work for your server (some hosts have unique setups), replace it with the full absolute path to public_html—for example: /home/yourusername/public_html/wp-content.

3. Confirm Site URL Settings

Since your site is deployed in a subfolder, you need to make sure WordPress knows where it's installed:

  • If you can access the WordPress admin (if not, use phpMyAdmin to edit your database):
    1. Go to Settings > General
    2. Set WordPress Address (URL) to your subfolder URL (e.g., https://yourdomain.com/blog)
    3. Set Site Address (URL) to your root domain (e.g., https://yourdomain.com)—this ensures media URLs don't include the subfolder.
  • If you can't access the admin, open your database via phpMyAdmin, find the wp_options table, update the siteurl option to your subfolder URL, and home to your root domain.

4. Check Your .htaccess File

Make sure the .htaccess file in your WordPress subfolder has the correct rewrite rules to handle the root-domain site address and the relocated wp-content. A standard setup for a subfolder install looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your-subfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /your-subfolder/index.php [L]
</IfModule>
# END WordPress

Replace /your-subfolder/ with your actual subfolder name.

5. Test and Debug

After making these changes:

  • Clear your browser cache and reload your site.
  • If you still see errors, check your server's error_log file (usually in public_html or your hosting control panel) for specific path-related errors—this will help pinpoint if WordPress is still looking for wp-content in the wrong place.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 07:44:45