0

I've been trying to move my WP site to a sub-directory, let's say /blog instead of mysite.com, i've been able to do this successfully in the past but now everything is going wrong. I followed several guides and here's what i tried so far:

  • Moved all wp-* files, index.php and .htaccess to the "blog" folder in /www/html after changing the URL in the wordpress dashboard;

  • Edited .htaccess to include redirects from several guides/questions i have found;

  • Added the following to wp-config.php:

      define('WP_HOME','https://www.example.com/landing');          
      define('WP_SITEURL','https://www.example.com/landing'); 
    
  • Deleted several plugins that i suspected were causing redirects or issues;

  • Edited index.php and added /blog to '/wp-blog-header.php';

  • Changed permissions of the "blog" folder where i placed the wordpress files;

  • Went into the sql database and altered the URL's in the wp-options table;

None of these things have worked and so far, i tried them separately and together, the furthest i got was getting the home page to load, wp-admin loads but only html and logging in does nothing. In all other instances i get 403 forbidden errors and 404 not found. If anyone knows what i'm missing, would appreciate it.

Note: I'm running on a vps so experimenting isn't an issue considering i have backups.

0

If you move a site, there are many instances in the database that have the URL hard-coded (media file pointers are one). You need to replace the old URL with the new one. You can do that with a search/replace plugin, or manually.

BUt the easiest way to do that, IMHO, is to use the "Clone" plugin from Automaticc. You install the plugin on the old and new sites (no matter where they are). You make sure the new site works at it's new (temporary) URL (like www.example.com/foldername).

So, install a brand new instance of WP on the new folder. Make sure you can log in there. Install the Clone plugin on the new place. Don't need anything else installed, as everything will be replaced.

Then you log into the old site, install the Clone plugin, and run the backup program. Copy the backup to local computer. Make sure you know the admin user account of the old site, because everything is replaced on the new site - user accounts also.

Then (in a new browser window), change your hosting to point the domain to the new folder (say 'foldername'). Change the URLs in the wp-options table manually to the domain name (from www.example.com/foldername to www.example.com). Make sure you can log into the new domain (with the new sites' credentials).

Install the Clone plugin on the new place (if not already there). Restore the site the zip file you saved locally. You'll then need to log in with credentials from the old place. And now www.example.com will be pointing to your subfolder.

Note: I'm not a big fan of making the URL change in the config file as you did. I like to have the correct URL in the wp-options table (in two places). Note that any URL settings in the config file override the wp-options settings - I just like it in wp-options so I don't confuse myself later on.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.