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

修改SiteURL与Home后WordPress站点故障,按规范操作仍未解决

Troubleshooting WordPress Site URL Change (from /wordpress to /blog) After Standard Steps Fail

Hey there, sorry to hear you're stuck after going through the usual checklist to update your WordPress site URL from www.mysite.com/wordpress to www.mysite.com/blog. Let's dive into some less obvious fixes that might be holding you back:

  • Check for hardcoded URLs in themes/plugins
    A lot of themes and lazy-coded plugins skip WordPress's native URL functions (like site_url() or home_url()) and hardcode the old URL directly. Use a search-replace tool to clean these up:

    • If you have WP-CLI access, run:
      wp search-replace 'www.mysite.com/wordpress' 'www.mysite.com/blog' --skip-columns=guid
      (The --skip-columns=guid flag is critical—don't overwrite post GUIDs, they're permanent identifiers.)
    • Without WP-CLI, use phpMyAdmin to search tables like wp_posts, wp_postmeta, and wp_options for the old URL, replacing instances where it appears (again, avoid touching the guid column).
  • Verify server configuration matches your setup
    The fix here depends on whether you moved WordPress files to a /blog directory or just want to map the URL to the existing /wordpress install:

    • If files stay in /wordpress:
      For Apache, update your root .htaccess to redirect /blog traffic to the /wordpress directory:
      RewriteEngine On
      RewriteRule ^blog/(.*)$ /wordpress/$1 [L]
      
      For Nginx, add this location block to your server config:
      location /blog {
          alias /path/to/your/wordpress;
          try_files $uri $uri/ /blog/index.php?$args;
      }
      
    • If you moved files to /blog:
      Double-check that your .htaccess is in the /blog directory with the correct rewrite base:
      RewriteEngine On
      RewriteBase /blog/
      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /blog/index.php [L]
      
      Also ensure Apache has AllowOverride All set for the /blog directory (so .htaccess rules are applied), or Nginx's root points to the right path.
  • Flush all caches
    Caches are the #1 culprit for lingering old URLs:

    • Force-refresh your browser (Ctrl+Shift+R on Windows/Linux, Cmd+Shift+R on Mac) to clear local cache.
    • Disable or flush any WordPress cache plugins (e.g., WP Rocket, W3 Total Cache) you're using.
    • Purge server-side caches (like Varnish) or CDN caches if you have them set up.
  • Double-check wp-config.php and wp_options for hidden issues

    • Confirm your wp-config.php defines the URLs correctly (place these lines before the "stop editing" comment):
      define('WP_SITEURL', 'https://www.mysite.com/blog');
      define('WP_HOME', 'https://www.mysite.com/blog');
      
      Don't forget to use https:// if your site uses SSL, and avoid trailing slashes unless you're sure you need them.
    • In wp_options, check beyond just siteurl and home—look for fields like upload_path, fileupload_url, or theme-specific options (e.g., logo URL, custom menu links) that might still reference the old URL.
  • Check file permissions
    Ensure your .htaccess file has the correct permissions (usually 644 for Apache) so the server can read it. If you're on Apache, also confirm that AllowOverride All is enabled in your VirtualHost or directory config—without this, .htaccess rules won't take effect.

Give these steps a shot in order—most of the time, it's a hidden hardcoded URL, misconfigured server rule, or stubborn cache causing the issue.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 07:15:11