Permanently Redirect Your WordPress Website to a New URL

I recently copied a client’s WordPress website from one domain to another.  In order to retain SEO for the old website, I needed to redirect every page on the old site to the same file on the new site.

If you’ve tried this before, you know that it is not easy to make sure you redirect EVERY possible url.

Here’s a foolproof way to create the exact code specifically for your website!

Don’t worry about changing the code that you got from someone else’s blog post and taking the chance on wreaking havoc with your website! Follow these 3 easy foolproof steps to redirect your old website links to your new website. Let’s get started.

Step 1

Create a Redirect

To create the code for the Redirect, log into your cPanel account. In the Domains Category, click on Redirects.

Enter the URL of you new website, and In order catch everything, check the Wild Card Redirect option and then click Add.

Doing this creates a list of Rewrite lines at the bottom of your .htaccess file. This step won’t work by itself, so now let’s edit the .htaccess file so that WordPress can take care of the redirect.

Step 2


Use your favorite FTP Client (I use FileZilla) to download the .htaccess file to your computer.

Step 3

Edit the .htaccess File

Open the .htaccess file. In the editor (I like Notepad++). Here you can see that Step 1 created a list of Rewrite lines at the end of the file. These lines will look something like this:

RewriteCond %{HTTP_HOST} ^.*$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ "https\:\/\/mynewsite\.com\/$1" [R=301,L]

Highlight (select) the lines and then use CTRL-X to cut these lines from the file. Then highlight (select) the WordPress Rewrite lines, usually at the top of the file, between

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /



And use CTRL-V to paste the new lines that cPanel created.

Save the .htaccess file and VOILA! Now anytime someone tries to find a page on the old website, it redirects to the new website, even specific pages and posts that are in the same file.

So now there’s no more having to figure out what code to use, let cPanel create it for you! It’s as easy as 1…2…3!

Leave a Reply

Your email address will not be published.

Back to top