Cpanel redirect all pages to new domain

A common task!

To redirect all pages from an old domain to a new domain using cPanel, you can follow these steps:

Method 1: Using the Redirects tool in cPanel

  1. Log in to your cPanel account.
  2. Click on the "Redirects" icon under the "Domains" section.
  3. Click on the "Add Redirect" button.
  4. In the "Redirect Type" dropdown, select "Permanent (301)".
  5. In the "Redirect from" field, enter the old domain (e.g., oldsite.com).
  6. In the "Redirect to" field, enter the new domain (e.g., newsite.com).
  7. Click the "Add Redirect" button.

This will redirect all pages from the old domain to the new domain. Note that this method only works for the root domain (e.g., oldsite.com) and not for subdomains.

Method 2: Using an.htaccess file

  1. Log in to your cPanel account.

  2. Click on the "File Manager" icon under the "Files" section.

  3. Navigate to the public_html directory (or the directory where your website files are located).

  4. Create a new file called .htaccess (if it doesn't already exist).

  5. Open the file in a text editor and add the following code:

    Redirect 301 / http://newsite.com/

    Replace newsite.com with your new domain.

  6. Save the file and upload it to the public_html directory.

This method will redirect all pages from the old domain to the new domain. Note that this method requires you to have access to the .htaccess file and may not work if your hosting provider has disabled .htaccess files.

Method 3: Using a rewrite rule in cPanel

  1. Log in to your cPanel account.

  2. Click on the "Apache Handlers" icon under the "Software" section.

  3. Click on the "Add New Apache Handler" button.

  4. In the "Handler" field, enter rewrite.

  5. In the "Rewrite Rule" field, enter the following code:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^oldsite.com [NC]
    RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L]

    Replace oldsite.com with your old domain and newsite.com with your new domain.

  6. Click the "Add Handler" button.

This method will redirect all pages from the old domain to the new domain. Note that this method requires you to have access to the Apache handlers and may not work if your hosting provider has disabled Apache handlers.

Remember to test your redirects by visiting a page on the old domain to ensure it redirects correctly to the new domain.