{"id":3834,"date":"2017-11-11T22:41:54","date_gmt":"2017-11-11T17:11:54","guid":{"rendered":"https:\/\/bogusblogging.com\/?p=3834"},"modified":"2021-09-04T06:23:13","modified_gmt":"2021-09-04T00:53:13","slug":"301-redirect-wordpress-site-htaccess","status":"publish","type":"post","link":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/","title":{"rendered":"How to 301 Redirect Your Old WordPress Site with Htaccess"},"content":{"rendered":"

If you have a self-hosted WordPress website, and you want to 301 redirect your old domain to your new domain (or any existing domain), you will need to follow the steps below.<\/p>\n

The task can be divided into four major subtasks such as:<\/p>\n

Task #1<\/strong>: Exporting (downloading) content of your old site (.xml format)
\nTask #2<\/strong>: Importing (uploading) .xml file to your new site
\nTask #3<\/strong>: Modifying your .htaccess file for 301 redirection
\nTask #4<\/strong>: Updating your property on Google Console (Webmaster Tools)<\/p>\n

Exporting and Importing .XML Files in WordPress<\/h2>\n

Both Task #1 and #2 are very easy if you\u2019re familiar with WordPress. However, I\u2019ll quickly walk you through the process to make sure you get a complete view.<\/p>\n

Step #1:<\/strong> Login to your old site\u2019s Dashboard and click on Export under Tools.<\/p>\n

Step #2<\/strong>: Click on \u201cDownload Export File\u201d if you want to transfer all content pieces as shown in the screenshot below.<\/p>\n

\"\"<\/p>\n

Otherwise, choose the kind of content you want to export and click on the download button. For example, if you want to export only blog posts and the featured images attached to them, then you will need to choose \u201cposts\u201d and \u201cmedia\u201d separately and download two files. Please, keep in mind, WordPress doesn\u2019t allow you to choose multiple options in one go.<\/p>\n

Step #3<\/strong>: Login to your new site\u2019s Dashboard and click on Import under Tools.<\/p>\n

Step #4<\/strong>: There, you can see various options to import your XML file(s) you downloaded in Step #2. Click on \u201cInstall Now\u201d under WordPress, and then click on Run Importer.<\/p>\n

\"\"<\/p>\n

Step #5<\/strong>: Once you run importer, you will see the following page (see screenshot below). Simply click on the \u201cChoose File\u201d button, and upload the .xml file(s) from your computer. It might ask you to assign your posts from your old site to the new site\u2019s author. Choose any names from the drop-down menu and click on Import.<\/p>\n

\"\"<\/p>\n

Depending on the size of your files, WordPress will process your request and display a status alert. For example, if you have around 50 posts, it should take about a minute.<\/p>\n

At this point, you\u2019re done with transferring content from your old domain to your new domain. It\u2019s time for the 301 redirection.<\/p>\n

Modifying your .htaccess File for 301 Redirection<\/h2>\n

There are some plugins that can help you do this if you\u2019re not very savvy with using the FTP. If you have the working knowledge of FTP, you can do this with the following steps:<\/p>\n

Step #1<\/strong>: Open Your FTP Client: I use Filezilla<\/p>\n

Step #2<\/strong>: Go to Your Root Folder and Locate the .htaccess File.<\/p>\n

Step #3<\/strong>: Download it to take a backup of the file first. If something goes wrong, you can always upload the original .htaccess file and restore your site.<\/p>\n

Step #4<\/strong>: Edit Your .htaccess File: Replace the existing code with the following code:<\/p>\n

#Use PHP 5.4
\n# Use PHP54 as default
\nAddHandler application\/x-httpd-php54 .php
\nsuPHP_ConfigPath \/opt\/php54\/lib
\nRewriteEngine on
\nRewriteCond %{HTTP_HOST} ^myoldwebsite.com [NC,OR]
\nRewriteCond %{HTTP_HOST} ^www.myoldwebsite.com [NC]
\nRewriteRule ^(.*)$ http:\/\/mynewdomain.com\/$1 [L,R=301,NC]
\n# BEGIN WPSuperCache
\n# END WPSuperCache
\n# BEGIN WordPress
\nRewriteEngine On
\nRewriteBase \/
\nRewriteRule ^index\\.php$ - [L]
\nRewriteCond %{REQUEST_FILENAME} !-f
\nRewriteCond %{REQUEST_FILENAME} !-d
\nRewriteRule . \/index.php [L]<\/p>\n

# END WordPress<\/code><\/p>\n

Important:<\/strong> Make sure you replace myoldwebsite.com with your old domain name in both instances. Likewise, replace http:\/\/mynewdomain.com with your new domain.<\/p>\n

Please, note that in both instances of RewriteCond, you need not add http or https to your old domain URL. However, in RewriteRule, you need to add the http or https to your new domain.<\/p>\n

Warning<\/strong>: If you\u2019re not sure about the above instruction, don\u2019t act in a hurry. It might lead to errors and your site might even break until you restore the old .htaccess file or fix the errors. Ask me about this in the comments at the end of the post.<\/p>\n

If you have followed me along, simply save your updated .htaccess file.<\/p>\n

Now, check both sites (old as well and new) to see if the redirection is working properly.<\/p>\n

Redirect The Entire Old Domain<\/h2>\n

What If you want to redirect the entire of the old domain (and not just blog posts) to your new domain address?<\/p>\n

Instead of the previous code, paste the following code in your old site\u2019s .htaccess file.<\/p>\n

RewriteEngine On
\nRewriteRule ^(.*)$ https:\/\/mynewdomain.com\/$1 [R,L]
\n# BEGIN WordPress
\nRewriteEngine On
\nRewriteBase \/
\nRewriteRule ^index\\.php$ - [L]
\nRewriteCond %{REQUEST_FILENAME} !-f
\nRewriteCond %{REQUEST_FILENAME} !-d
\nRewriteRule . \/index.php [L]
\n# END WordPress<\/code><\/p>\n

Once you have saved your work and checked that everything is working well, head over to Google Console (Webmaster Tools) and tell Google Search Engine about the transfer.<\/p>\n

Updating your Property on Google Console<\/h2>\n

Even as you have completed the 301 Redirection, you still need to update your property on Google Console to make sure Google start indexing the content in the new domain address.<\/p>\n

Simply, head over to Google Console and choose the property associated with your old website domain name. Once on Dashboard, look to the right-hand side, locate the cog icon and click on it. You will see the drop-down menu (as shown in the screenshot below<\/em>).<\/p>\n

\"\"<\/p>\n

Click on Change of Address in the menu, and you will see the following screen.<\/p>\n

At this point, Google may already have tracked the 301 redirection and ticked the first two boxes for you (see screenshot below). You just need to click on the Confirm Option, and then on Submit Option.<\/p>\n

\"\"<\/p>\n

Google Console will confirm your request and show you a box stating \u201cSubmitted\u201d. It also allows you to withdraw your request at any time in the future.<\/p>\n

Go to Google Search, and type site:myolddomain.com<\/p>\n

You will see a list of URLs from your old domain that Google has indexed so far. In a few weeks after your submission for the Change of Address request, you should see those links disappear.<\/p>\n

Hope you found this post useful. If you do, don\u2019t forget to share it with your friends. Don’t\u2019 hesitate to leave a comment, question, feedback if you believe otherwise.<\/p>\n","protected":false},"excerpt":{"rendered":"

Learn how to 301 redirect your old WordPress site to a new domain using htaccess. <\/p>\n","protected":false},"author":1,"featured_media":3889,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[4],"tags":[464],"yoast_head":"301 Redirect htaccess Wordpress: Redirect Your Old Site to New Domain<\/title>\n<meta name=\"description\" content=\"301 Redirect htaccess Wordpress: Learn how to 301 redirect your old WordPress site to a new domain using htaccess in this easy-to-follow guide.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"301 Redirect htaccess Wordpress: Redirect Your Old Site to New Domain\" \/>\n<meta property=\"og:description\" content=\"301 Redirect htaccess Wordpress: Learn how to 301 redirect your old WordPress site to a new domain using htaccess in this easy-to-follow guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/\" \/>\n<meta property=\"og:site_name\" content=\"SUSANTA\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-11T17:11:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-04T00:53:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Susanta\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Susanta\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/\"},\"author\":{\"name\":\"Susanta\",\"@id\":\"https:\/\/susanta.org\/#\/schema\/person\/d928245582ea7800b16ebe767c5b7e10\"},\"headline\":\"How to 301 Redirect Your Old WordPress Site with Htaccess\",\"datePublished\":\"2017-11-11T17:11:54+00:00\",\"dateModified\":\"2021-09-04T00:53:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/\"},\"wordCount\":918,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/susanta.org\/#\/schema\/person\/d928245582ea7800b16ebe767c5b7e10\"},\"image\":{\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png\",\"keywords\":[\"WordPress\"],\"articleSection\":[\"SEO\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/\",\"url\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/\",\"name\":\"301 Redirect htaccess Wordpress: Redirect Your Old Site to New Domain\",\"isPartOf\":{\"@id\":\"https:\/\/susanta.org\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png\",\"datePublished\":\"2017-11-11T17:11:54+00:00\",\"dateModified\":\"2021-09-04T00:53:13+00:00\",\"description\":\"301 Redirect htaccess Wordpress: Learn how to 301 redirect your old WordPress site to a new domain using htaccess in this easy-to-follow guide.\",\"breadcrumb\":{\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#primaryimage\",\"url\":\"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png\",\"contentUrl\":\"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png\",\"width\":1200,\"height\":600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/susanta.org\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to 301 Redirect Your Old WordPress Site with Htaccess\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/susanta.org\/#website\",\"url\":\"https:\/\/susanta.org\/\",\"name\":\"SUSANTA\",\"description\":\"Blog About Digital Marketing\",\"publisher\":{\"@id\":\"https:\/\/susanta.org\/#\/schema\/person\/d928245582ea7800b16ebe767c5b7e10\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/susanta.org\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/susanta.org\/#\/schema\/person\/d928245582ea7800b16ebe767c5b7e10\",\"name\":\"Susanta\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/susanta.org\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/susanta.org\/wp-content\/uploads\/2020\/12\/Susanta-Blog-Logo-.svg\",\"contentUrl\":\"https:\/\/susanta.org\/wp-content\/uploads\/2020\/12\/Susanta-Blog-Logo-.svg\",\"width\":\"1024\",\"height\":\"1024\",\"caption\":\"Susanta\"},\"logo\":{\"@id\":\"https:\/\/susanta.org\/#\/schema\/person\/image\/\"}}]}<\/script>","yoast_head_json":{"title":"301 Redirect htaccess Wordpress: Redirect Your Old Site to New Domain","description":"301 Redirect htaccess Wordpress: Learn how to 301 redirect your old WordPress site to a new domain using htaccess in this easy-to-follow guide.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/","og_locale":"en_US","og_type":"article","og_title":"301 Redirect htaccess Wordpress: Redirect Your Old Site to New Domain","og_description":"301 Redirect htaccess Wordpress: Learn how to 301 redirect your old WordPress site to a new domain using htaccess in this easy-to-follow guide.","og_url":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/","og_site_name":"SUSANTA","article_published_time":"2017-11-11T17:11:54+00:00","article_modified_time":"2021-09-04T00:53:13+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png","type":"image\/png"}],"author":"Susanta","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Susanta","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#article","isPartOf":{"@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/"},"author":{"name":"Susanta","@id":"https:\/\/susanta.org\/#\/schema\/person\/d928245582ea7800b16ebe767c5b7e10"},"headline":"How to 301 Redirect Your Old WordPress Site with Htaccess","datePublished":"2017-11-11T17:11:54+00:00","dateModified":"2021-09-04T00:53:13+00:00","mainEntityOfPage":{"@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/"},"wordCount":918,"commentCount":1,"publisher":{"@id":"https:\/\/susanta.org\/#\/schema\/person\/d928245582ea7800b16ebe767c5b7e10"},"image":{"@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png","keywords":["WordPress"],"articleSection":["SEO"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/","url":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/","name":"301 Redirect htaccess Wordpress: Redirect Your Old Site to New Domain","isPartOf":{"@id":"https:\/\/susanta.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#primaryimage"},"image":{"@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png","datePublished":"2017-11-11T17:11:54+00:00","dateModified":"2021-09-04T00:53:13+00:00","description":"301 Redirect htaccess Wordpress: Learn how to 301 redirect your old WordPress site to a new domain using htaccess in this easy-to-follow guide.","breadcrumb":{"@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#primaryimage","url":"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png","contentUrl":"https:\/\/susanta.org\/wp-content\/uploads\/2017\/11\/301-Redirect-WordPress.png","width":1200,"height":600},{"@type":"BreadcrumbList","@id":"https:\/\/susanta.org\/301-redirect-wordpress-site-htaccess\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/susanta.org\/"},{"@type":"ListItem","position":2,"name":"How to 301 Redirect Your Old WordPress Site with Htaccess"}]},{"@type":"WebSite","@id":"https:\/\/susanta.org\/#website","url":"https:\/\/susanta.org\/","name":"SUSANTA","description":"Blog About Digital Marketing","publisher":{"@id":"https:\/\/susanta.org\/#\/schema\/person\/d928245582ea7800b16ebe767c5b7e10"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/susanta.org\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/susanta.org\/#\/schema\/person\/d928245582ea7800b16ebe767c5b7e10","name":"Susanta","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/susanta.org\/#\/schema\/person\/image\/","url":"https:\/\/susanta.org\/wp-content\/uploads\/2020\/12\/Susanta-Blog-Logo-.svg","contentUrl":"https:\/\/susanta.org\/wp-content\/uploads\/2020\/12\/Susanta-Blog-Logo-.svg","width":"1024","height":"1024","caption":"Susanta"},"logo":{"@id":"https:\/\/susanta.org\/#\/schema\/person\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/posts\/3834"}],"collection":[{"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/comments?post=3834"}],"version-history":[{"count":0,"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/posts\/3834\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/media\/3889"}],"wp:attachment":[{"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/media?parent=3834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/categories?post=3834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/susanta.org\/wp-json\/wp\/v2\/tags?post=3834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}