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

将XAMPP开发的静态HTML网站迁移至WordPress并替换现有站点求助

Replace WordPress with Your Static XAMPP Site: Step-by-Step Guide

Hey there! I’ve helped folks swap out WordPress for static sites plenty of times—let’s get yours sorted without any headaches. Here’s a straightforward, actionable plan:

1. First, Backup Everything (Critical!)

Don’t skip this—you’ll thank me if something goes sideways.

  • Backup WordPress files: In your XAMPP htdocs folder, find your WordPress site’s root directory (e.g., htdocs/my-wordpress-site). Copy the entire folder to a safe location (like your desktop or an external drive).
  • Backup WordPress database: Open XAMPP’s phpMyAdmin (usually at localhost/phpmyadmin), select your WordPress database, click the "Export" tab, choose "Quick" export method, and save the SQL file to your backup location.

2. Prep Your Static Site Files

Make sure your static site is organized properly:

  • Your main homepage should be named index.html (or index.htm—Apache prioritizes these by default).
  • All supporting files (CSS, JS, images, fonts) should be in subfolders (e.g., css/, js/, images/) within your static site’s root folder.
  • Double-check that all internal links and resource paths are relative (e.g., ./css/style.css instead of http://localhost/my-site/css/style.css)—this ensures they work when you move the site to the root.

3. Swap Out the Files

Now let’s replace WordPress with your static content:

  • Go back to your XAMPP site’s root directory (where WordPress was installed). Delete or move all WordPress-specific files/folders (e.g., wp-admin/, wp-includes/, wp-content/, wp-config.php, etc.) to your backup folder—leave nothing except maybe the .htaccess file (we’ll edit that next).
  • Copy all your static site files (including index.html and subfolders) into this root directory.

4. Fix the .htaccess File

WordPress uses .htaccess for rewrite rules—we need to update it for your static site:

  • Open the .htaccess file in a text editor (like Notepad++ or VS Code).
  • Delete all existing WordPress rewrite rules (they’ll look something like RewriteEngine On followed by multiple RewriteRule lines).
  • Replace it with this basic configuration to set your static homepage and handle clean URLs:
DirectoryIndex index.html index.htm
# Optional: Redirect old WordPress URLs to new static pages (adjust paths as needed)
# Redirect 301 /old-wordpress-post/ /new-static-page.html
  • Save the file and upload it back to the root directory (if you edited it locally).

5. Test Your Site

Fire up XAMPP’s Apache server, then visit your site (e.g., localhost/my-site). Check:

  • Does the homepage load correctly?
  • Are all images, CSS, and JS files loading (right-click > "Inspect" > "Console" to check for errors)?
  • Do all internal links work?
  • If you had custom URLs in WordPress, test any redirects you added in .htaccess.

Troubleshooting Common Issues

  • 404 Errors:
    • Make sure DirectoryIndex in .htaccess includes index.html (Apache might be looking for index.php by default).
    • Check that XAMPP’s Apache configuration (httpd.conf) allows .htaccess overrides—look for AllowOverride All in the <Directory "htdocs"> section.
  • Broken Resource Links:
    • Verify your relative paths are correct (e.g., if your CSS is in css/style.css, the link in index.html should be <link rel="stylesheet" href="./css/style.css">).
  • Old WordPress Content Showing Up:
    • Clear your browser cache (press Ctrl+F5 to force a hard refresh) or use incognito mode to test.

That’s it! Once everything checks out, your static site should be live and replacing the old WordPress install.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:20:20