Search This Blog

404 Error While Accessing Drupal Site After Migration


404 Error While Accessing Drupal Site After Migration
If you have migrated a Drupal site from local development server to a live server or from one host to another host, you will generally encounter a 404 error when accessing the pages after migration. Do not freak out, this is pretty normal and can be resolved easily. Let's go through what I did so far to migrate from one host to another.

Process of migrating a Drupal Site from one host to another host:

On the old server:

  1. Preparation on the website
    1. Logged in as Admin
    2. Disabled clean URLs (Administration » Configuration » Search and metadata ) 
    3. Flushed all cache
  2. Backup Site Files
    1. Logged in to the old host account
    2. Accessed File Manager (Cpanel)
    3. Right-clicked on public_html and compress (created a zip file- public_html.zip)
    4. rename the public_html.zip to sitebackup.zip
    5. Downloaded the sitebackup.zip file
  3. Backup the database
    1. From the Cpanel, accessed "phpMyAdmin"
    2. Exported the database
  4. If you want you can also download and backup email accounts, email forwarders etc. Refer to backup section in Cpanel

On the New Server

  1. Restore the Drupal Site files
    1. Logged in to the old host account
    2. Accessed File Manager (Cpanel)
    3. Opened public_html
    4. Uploaded the sitebackup.zip file from the old server
    5. Extracted sitebackup.zip file (a folder is created by the name of the zip file i.e. sitebackup)
    6. Opened sitebackup folder
    7. Copied all contents from sitebackup folder and moved to public_html folder  
    8. Deleted sitebackup folder
  2. Creating a new database
    1. Accessed Cpanel > MySqlDatabases
    2. Created a new database. (Noted the name of the database)
    3. Created a new user for the new database created and set password (noted the username and the password)
  3. Restoring the database
    1. Accessed Cpanel > phpMyAdmin
    2. Clicked on the new database
    3. Imported the database file from old server to this one
  4. Changing Settings.php
    1. Accessed Cpanel > File Manager
    2. Navigated to the folder "public_html/sites/default/" and downloaded a copy of settings.php. Then deleted the existing setting.php copy under "public_html/sites/default/"
    3. Edited the downloaded settings.php file - edited database properties in settings.php with the new database name, database username and password
    4. Uploaded the edited setting.php file to "public_html/sites/default/"
  5. Opened the site in a browser. Home page displayed. But on clicking the other links, "404 error" encountered. 
  6. Attempted to login site.com/?=user but the recaptcha not displaying.So unable to login. (You can also enable "$update_free_access = TRUE;" in settings.php to run update.php. But I didn't do that.
  7. Checked "public_html" and there is no .htaccess file
  8. Extracted the sitebackup.zip again. The progress log of extracting shows .htaccess file being extracted. But .htaccess file is not found in the extract sitebackup folder.
  9. On the local computer, extracted the sitebackup.zip file which was downloaded to my computer earlier.
  10. Uploaded the .htaccess to public_html but the file is still not visible.
  11. On the local computer, renamed .htaccess to htaccess (without the dot)
  12. Uploaded htaccess (without the dot) to public_html
  13. Renames htaccess to .htaccess
  14. On the browser, opened the website.
  15. Bingo! Site is working now



Sponsored Links


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...