CiviCRM Page Not Found Error After Copying Site to New Server
We Always make a tar.gz from all the files, and a database backup of the drupal database and the civicrm database, without disabeling any modules.
The we extract the files on the new location, and give the files and folder the right permissions (in most case 755 is good and do not forget the .htaccess). Then we ajust the settings.php and the civicrm.settings.php, with the correct paths and database connection information. Than we change the "Temporary directory" in the "File system" in drupal, and the paths in "Directories", "Resource URL's" and "Cache" in civicrm. Clear the cache again and that's it!

Don not change anything on your current website!


cd /var/www/html
tar cvzf mywebsite.tar.gz mywebsite/
mysqldump -u database_user_drupal -p database_name_drupal > database_name_drupal.sql
mysqldump -u database_user_civicrm -p database_name_civicrm > database_name_civicrm.sql
Copy everything to the new server and do
tar -xvf mywebsite.tar.gz
cp -rf mywebsite/ /var/www/html/mywebsitelocation
chown -R username:www-data /var/www/html/mywebsitelocation/
chmod -R 755 /var/www/html/mywebsitelocation (or 775 for testing)
check the username of the DEFINER in the database_name.civicrm.sql


with:
sed -n '/DEFINER/p' database_name.civicrm.sql
remove it with:
sed -i 's#DEFINER=username@%# #g' database_name.civicrm.sql (replace username)
and:
sed -i 's#DEFINER=username@localhost# #g' database_name.civicrm.sql (replace username)
and:
sed -i 's#SQL SECURITY DEFINER#SQL SECURITY INVOKER#g' database_name.civicrm.sql

mysql -u new_database_user_drupal -p new_database_name_drupal &lt; database_name_drupal.sql
mysql -u new_database_user_civicrm -p new_database_name_civicrm &lt; database_name_drupal.sql
nano /var/www/html/mywebsitelocation/sites/default/settings.php


change the "$databases = array ("
change the "$base_url =" (if set)

nano /var/www/html/mywebsitelocation/sites/default/civicrm.settings.php


change "define( 'CIVICRM_UF_DSN'"
change "define('CIVICRM_DSN'"
change "$civicrm_root ="
change "define( 'CIVICRM_TEMPLATE_COMPILEDIR'"
change "define( 'CIVICRM_UF_BASEURL'"
we do not use the "$civicrm_setting['Directory Preferences']" settings and "$civicrm_setting['URL Preferences']" settings in the civicrm.settings.php

change the "Temporary directory" in the "File system" in drupal
clear the cache, use the button in drupal
"Reset Paths" on "civicrm/admin/setting/updateConfigBackend?reset=1"
and you can clear the cache in civicrm also with the button on "civicrm/admin/setting/updateConfigBackend?reset=1"