When I migrated the WordPress site from one server to another. Pages are not found, the error is coming while accessing the pages. I have updated the wp-config, .htaccess files and also changed the links and URL with the new site URL in the tables.
I have followed the below steps:
wp-config.php
define( 'DB_NAME', 'my-db-name' );
define( 'DB_USER', 'my-db-user' );
define( 'DB_PASSWORD', 'my-db-pwd' );
define( 'DB_HOST', 'localhost' );
WordPress Setting
Settings->
WordPress Address (URL) - New-URL
Site Address (URL) - New-URL
.htacess.php
Generate the .htacess from Permalink Settings
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder-name/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folder-name/index.php [L]
</IfModule>
Database queries
Updated tables wp_options , wp_posts , wp_usermeta, wp_links , wp_comments
Example:
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
The requested URL /New-URL/folder-name/page-name was not found on this server Apache/2.4.7 (Ubuntu) Server at New-URL Port 80
If permalinks are refreshed and you updated the database also, you probably have htaccess problems.
.htaccess
should be spelled with double c, and should not have .php extension. You also have to update the folder-name
inside to the actual folder you are using.
.htaccess
file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder-name/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folder-name/index.php [L]
</IfModule>
# END WordPress
Also check out this .htaccess file: https://wordpress.org/support/article/giving-wordpress-its-own-directory/#method-i-without-url-change