简体   繁体   中英

Errors after moving local Wordpress site outside of XAMPP\htdocs

Background

As someone who develops multiple websites I wanted to be able to serve each site from within its respective project folder in the filesystem, instead of serving them all under the htdocs directory.

So I moved my wordpress folder (whose site was usually accessed via localhost/wordpress ) to my project directory, and followed the instructions in this answer to set up a virtual host with a DocumentRoot and Directory that matches the new location of the wordpress folder. This is the whole (uncommented portion) of my httpd-vhosts.conf :

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "D:\Users\User\Documents\Projects\Websites\My New Project\wordpress"
    ServerName localhost.irm
    <Directory "D:\Users\User\Documents\Projects\Websites\My New Project\wordpress">
    Options FollowSymLinks 
    AllowOverride All
        Require all granted  
    </Directory>
</VirtualHost>

The Problem

The homepage can now be found at localhost.irm , but it's text-only, with no styles or images, and clicking on any page takes me to an "Object not found." XAMPP page.

What I've Tried

  • Accessed the database with PHPMyAdmin, changing siteurl and home in the wp_options table to reflect the new domain

  • Used the WP-CLI tool to search-and-replace all database instances of the old domain with the new one

Unfortunately none of these solved the problem.

This seemed to be primarily caused by two problems:

  1. The Site Ground Optimiser plugin from my live site that I wasn't even aware was activated on my local site. Deactivating using wp plugin deactivate sg-cachepress (the WP-CLI tool) solved that.

  2. The following line in my .htaccess file, at the root of my Wordpress site:

     RewriteBase /wordpress/

    I assume it must have been necessary to add for my previous setup and I'd since forgotten about it. Either way, removing/commenting the line out entirely seems to have solved the rest of the problem.

I'm now able to access my website with all styles and images, just like I was before, with the advantage that my files are now being served from my project folder itself instead of from XAMPP\htdocs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM