{"id":34436,"date":"2021-10-20T15:41:19","date_gmt":"2021-10-20T15:41:19","guid":{"rendered":"https:\/\/www.hostduplex.com\/kb\/?post_type=ht_kb&#038;p=34436"},"modified":"2021-11-01T21:38:46","modified_gmt":"2021-11-01T21:38:46","slug":"how-to-set-up-a-301-permanent-redirect-using-htaccess","status":"publish","type":"ht_kb","link":"https:\/\/www.hostduplex.com\/kb\/article\/how-to-set-up-a-301-permanent-redirect-using-htaccess\/","title":{"rendered":"How to set up a 301 Permanent Redirect using .htaccess"},"content":{"rendered":"\n<p>After moving to a new domain, or moving old site pages to a new site structure, you can use 301 redirects to permanently send visitors to a new URL and tell search engines that a page has moved.<\/p>\n\n\n\n<p>You can set up the redirect by editing your .htaccess file using your control panel. For the purposes of this article, we will be using cPanel.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Redirecting to another page<\/h3>\n\n\n\n<p>1. Log in to your cPanel account<\/p>\n\n\n\n<p>2. Go to the File Manager. You can scroll down to the Files section or use the search bar to find it<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"429\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1024x429.jpg\" alt=\"\" class=\"wp-image-34553\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1024x429.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-300x126.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-768x322.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-50x21.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1536x644.jpg 1536w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-60x25.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-100x42.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager.jpg 1978w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>3. On the public_html folder, look for the .htacces file. Right click on it and select Edit<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"754\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-1024x754.jpg\" alt=\"\" class=\"wp-image-34426\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-1024x754.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-300x221.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-768x566.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-50x37.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-60x44.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-100x74.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3.jpg 1533w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>4. This window will show up. Just click on Edit<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"471\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1-1024x471.jpg\" alt=\"\" class=\"wp-image-34564\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1-1024x471.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1-300x138.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1-768x353.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1-50x23.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1-1536x706.jpg 1536w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1-60x28.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1-100x46.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1.jpg 1799w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>5. Add the following code at the top of the file <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RedirectPermanent http:\/\/www.domain.com\/old-file.html http:\/\/www.domain.com\/new-file.html<\/pre>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">Make sure to replace the URLs on the snippet of code with your own<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"535\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/301-1024x535.jpg\" alt=\"\" class=\"wp-image-34437\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/301-1024x535.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/301-300x157.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/301-768x401.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/301-50x26.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/301-60x31.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/301-100x52.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/301.jpg 1417w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>6. Click the Save Changes button on the top right. You will see a Success message, you can now close the editor<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"508\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1-1024x508.jpg\" alt=\"\" class=\"wp-image-34566\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1-1024x508.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1-300x149.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1-768x381.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1-50x25.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1-1536x762.jpg 1536w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1-60x30.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1-100x50.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/htaccess-1.jpg 1792w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Redirect to a new domain<\/h3>\n\n\n\n<p>If you want to redirect to a different domain, follow the steps above and use the following code on step 5.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RedirectPermanent \/ http:\/\/www.new-domain.com\/<\/pre>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">Make sure to replace<strong> https:\/\/www.new-domain.com\/ <\/strong>with your domain<\/p>\n\n\n\n<p>It should look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"658\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/3012-1024x658.jpg\" alt=\"\" class=\"wp-image-34438\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/3012-1024x658.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/3012-300x193.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/3012-768x494.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/3012-50x32.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/3012-60x39.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/3012-100x64.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/3012.jpg 1101w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-background has-purple-background-color has-purple-color is-style-default\"\/>\n\n\n\n<p>If you are a Host Duplex customer and still have questions, please open a ticket in the&nbsp;<a href=\"https:\/\/secure.hostduplex.com\/clientarea.php\" target=\"_blank\" rel=\"noopener\">Host Duplex client portal.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>After moving to a new domain, or moving old site pages to a new site structure, you can use 301 redirects to permanently send visitors to a new URL and tell search engines that a page has moved. You can set up the redirect by editing your .htaccess file using&#8230;<\/p>\n","protected":false},"author":2,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"ht-kb-category":[20,3],"ht-kb-tag":[190,23,187,208,189],"class_list":["post-34436","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-cpanel","ht_kb_category-account-management","ht_kb_tag-301-redirect","ht_kb_tag-cpanel","ht_kb_tag-htaccess","ht_kb_tag-new-domain","ht_kb_tag-redirect"],"_links":{"self":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/comments?post=34436"}],"version-history":[{"count":5,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34436\/revisions"}],"predecessor-version":[{"id":34567,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34436\/revisions\/34567"}],"wp:attachment":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/media?parent=34436"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=34436"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=34436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}