This are the steps, what I have done to make it success !,
1. Change the root folder name from \htdocs\OldSiteName to \htdocs\NewSiteName .
2. Change the wp-config.php
From,
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/OldSiteName');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/OldSiteName');
To,
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/NewSiteName');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/NewSiteName');
3. Change the content in the .htaccess file
From,
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /OldSiteName/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /OldSiteName/index.php [L]
</IfModule>
To,
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NewSiteName/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NewSiteName/index.php [L]
</IfModule>
4. Execute the scripts to change the values in the database.
UPDATE wp_options
SET option_value = 'http://127.0.0.1/NewSiteName'
WHERE option_name = 'home';
UPDATE wp_options
SET option_value = 'http://127.0.0.1/NewSiteName'
WHERE option_name = 'siteurl';
UPDATE wp_posts
SET post_content = REPLACE(post_content,'http://127.0.0.1/OldSiteName','http://127.0.0.1/NewSiteName');
UPDATE wp_posts
SET guid = REPLACE(guid,'http://127.0.0.1/OldSiteName','http://127.0.0.1/NewSiteName');
These are all the steps that I have done to make all the pages and inter links to get worked. eg: Clicking menu should take it the correct page.
Note : Reference link : https://wordpress.org/support/article/changing-the-site-url/