Redirect old wordpress site to new wordpress domain

In this article I will short show you how to redirect an old domain to a new domain using HTACCESS. First you have to either create a .HTACCESS file and put it in the root of your domain. Alternative you can install the plugin WordPress SEO and choose Edit files and then edit the HTACCESS file directly from there.

Then you insert the following code:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^newdomain.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule>
# END WordPress

In this code you will both redirect a whole old domain olddomain.com to a new domain newdomain.com – and redirect the not-WWW version of your new domain til the WWW-version of your new domain.

 

0 0 votes
Article Rating

Andreas Andersen

Forfatter og grundlægger af IT-blogger.dk, der har blogget om IT-emner siden 2012. Findes på Mastodon på @aphandersen@ansico.dk

Abonner
Giv besked ved
guest

0 Comments
mest stemt på
nyeste ældste
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x