Search code examples
wordpress.htaccessmigrationsubdirectory

Wordpress can't login to wp-admin after moving site to subfolder


I'm new to Wordpress. Basically I just wanted to move the site from the root www folder to a subfolder.

I have access to the frontend site, but not the admin panel.

I did this steps:

1- Change Wordpress Address URL to http://example.com/subfolder

2- move all files to subfolder, and copy index.php and .htaccess to root folder

3- change index.php code line to require( dirname( __FILE__ ) . '/m4thod.com2/wp-blog-header.php' );

4- in .htaccess public_html I tried with this rules but I commented it.

#<IfModule mod_rewrite.c>
#RewriteEngine On
#RewriteCond %{HTTP_HOST} ^(www.)?m4thod.com$
#RewriteRule ^(/)?$ m4thod.com2[L]
#</IfModule>

5- added this lines to wp-config.php

define('WP_SITEURL', 'http://example.com/subdirectory/');
define('WP_HOME', 'http://example.com/');

define('WP_CONTENT_URL', 'http://example.com/subdirectory/');

I don't know if it's the .htaccess file, I have .htaccess in public_html and public_html/subfolder

I normally do this kind of migrations in Magento 2 with Apache server in a VM, but I'm struggling with this hosting and wordpress. I'm using Blue Host btw.

UPDATE: I get Interna error 500. And this is the way I access

https://example.com/subdirectory/wp-login.php

Greetings!


Solution

  • The conflict arises due to incorrect .htaccess. Put the .htaccess file in the root folder and original index.php file copy to the subfolder. without edit require( dirname( __FILE__ ) . '/wp-blog-header.php' ); . Modify the .htaccess for the WordPress site in the subdirectory to include the subfolder name. For example:

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