{"id":2958,"date":"2017-07-20T12:02:16","date_gmt":"2017-07-20T06:32:16","guid":{"rendered":"https:\/\/code4developers.com\/?p=2958"},"modified":"2017-07-20T12:02:16","modified_gmt":"2017-07-20T06:32:16","slug":"301-redirects-redirect-website","status":"publish","type":"post","link":"https:\/\/code4developers.com\/301-redirects-redirect-website\/","title":{"rendered":"301 Redirects \u2013 How to Redirect your Website?"},"content":{"rendered":"<p>A 301 Redirect is the most efficient and Search Engine Friendly method for webpage redirection. It\u2019s not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it\u2019s the safest option. The code \u201c301\u201d is interpreted as \u201cmoved permanently\u201d.<\/p>\n<p><!--more--><\/p>\n<p><strong>You can Test your redirection with <a href=\"http:\/\/webconfs.com\/redirect-check.php\" target=\"_blank\" rel=\"noopener\">Search Engine Friendly Redirect Checker<\/a><\/strong><\/p>\n<p><img  loading=\"lazy\"  decoding=\"async\"  data-attachment-id=\"2964\"  data-permalink=\"https:\/\/code4developers.com\/301-redirects-redirect-website\/do-a-301-redirect\/\"  data-orig-file=\"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?fit=580%2C304&amp;ssl=1\"  data-orig-size=\"580,304\"  data-comments-opened=\"1\"  data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\"  data-image-title=\"Do-a-301-Redirect\"  data-image-description=\"\"  data-image-caption=\"\"  data-medium-file=\"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?fit=300%2C157&amp;ssl=1\"  data-large-file=\"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?fit=580%2C304&amp;ssl=1\"  class=\"aligncenter wp-image-2964 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkQAAAEwAQMAAABsdfxTAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAC1JREFUeNrtwTEBAAAAwqD1T20Gf6AAAAAAAAAAAAAAAAAAAAAAAAAAAACA1wBX4AAB+TlvGgAAAABJRU5ErkJggg==\"  alt=\"How to Implement 301 Redirect\"  width=\"580\"  height=\"304\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 580px) 100vw, 580px\"  data-pk-src=\"https:\/\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg\"  data-pk-srcset=\"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?w=580&amp;ssl=1 580w, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?resize=300%2C157&amp;ssl=1 300w, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?resize=120%2C63&amp;ssl=1 120w, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?resize=90%2C47&amp;ssl=1 90w, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?resize=320%2C168&amp;ssl=1 320w, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?resize=560%2C294&amp;ssl=1 560w, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?resize=240%2C126&amp;ssl=1 240w, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/Do-a-301-Redirect.jpg?resize=180%2C94&amp;ssl=1 180w\" ><\/p>\n<p>&nbsp;<\/p>\n<p>Below are a Couple of methods to implement <strong>URL Redirection via code and htaccess redirect.<\/strong><\/p>\n<h3 id=\"iis-redirect\"><strong>IIS Redirect<\/strong><\/h3>\n<ul>\n<li>In internet services manager, right-click on the file or folder you wish to redirect<\/li>\n<li>Select the radio titled \u201ca redirection to a URL\u201d.<\/li>\n<li>Enter the redirection page<\/li>\n<li>Check \u201cThe exact url entered above\u201d and the \u201cA permanent redirection for this resource\u201d<\/li>\n<li>Click on \u2018Apply\u2019<\/li>\n<\/ul>\n<h3 id=\"coldfusion-redirect\"><strong>ColdFusion Redirect<\/strong><\/h3>\n<pre class=\"lang:default decode:true\">&lt;.cfheader statuscode=\u201d301\u2033 statustext=\u201dMoved permanently\u201d&gt;\r\n&lt;.cfheader name=\u201dLocation\u201d value=\u201dhttp:\/\/www.new-url.com\u201d&gt;<\/pre>\n<h3 id=\"php-redirect\">PHP Redirect<\/h3>\n<pre class=\"lang:default decode:true\">&lt;?\r\nHeader( \u201cHTTP\/1.1 301 Moved Permanently\u201d );\r\nHeader( \u201cLocation: http:\/\/www.new-url.com\u201d );\r\n?&gt;<\/pre>\n<h3 id=\"asp-redirect\">ASP Redirect<\/h3>\n<pre class=\"lang:default decode:true\">&lt;%@ Language=VBScript %&gt;\r\n&lt;%\r\nResponse.Status=\u201d301 Moved Permanently\u201d\r\nResponse.AddHeader \u201cLocation\u201d,\u201dhttp:\/\/www.new-url.com\/\u201d\r\n%&gt;<\/pre>\n<h3 id=\"asp-net-redirect\">ASP .NET Redirect<\/h3>\n<pre class=\"lang:default decode:true\">&lt;script runat=\u201dserver\u201d&gt;\r\nprivate void Page_Load(object sender, System.EventArgs e)\r\n{\r\nResponse.Status = \u201c301 Moved Permanently\u201d;\r\nResponse.AddHeader(\u201cLocation\u201d,\u201dhttp:\/\/www.new-url.com\u201d);\r\n}\r\n&lt;\/script&gt;<\/pre>\n<h3 id=\"jsp-java-redirect\"><strong>JSP (Java) Redirect<\/strong><\/h3>\n<pre class=\"lang:default decode:true\">&lt;%\r\nresponse.setStatus(301);\r\nresponse.setHeader( \u201cLocation\u201d, \u201chttp:\/\/www.new-url.com\/\u201d );\r\nresponse.setHeader( \u201cConnection\u201d, \u201cclose\u201d );\r\n%&gt;<\/pre>\n<h3 id=\"cgi-perl-redirect\"><strong>CGI PERL Redirect<\/strong><\/h3>\n<pre class=\"lang:default decode:true\">$q = new CGI;\r\nprint $q-&gt;redirect(\u201chttp:\/\/www.new-url.com\/\u201d);<\/pre>\n<h3 id=\"ruby-on-rails-redirect\"><strong>Ruby on Rails Redirect<\/strong><\/h3>\n<pre class=\"lang:default decode:true\">def old_action\r\nheaders[\u201cStatus\u201d] = \u201c301 Moved Permanently\u201d\r\nredirect_to \u201chttp:\/\/www.new-url.com\/\u201d\r\nend<\/pre>\n<h3 id=\"redirect-old-domain-to-new-domain-using-htaccess-redirect\"><strong>Redirect Old domain to New domain using htaccess redirect<\/strong><\/h3>\n<p>Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.<br \/>\nThe .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)<\/p>\n<pre class=\"lang:default decode:true\">Options +FollowSymLinks\r\nRewriteEngine on\r\nRewriteRule (.*) http:\/\/www.newdomain.com\/$1 [R=301,L]<\/pre>\n<p>Please REPLACE www.newdomain.com in the above code with your actual domain name.<\/p>\n<p>In addition to the redirect I would suggest that you contact every backlinking site to modify their backlink to point to your new website.<\/p>\n<p><strong>Note*<\/strong> This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.<\/p>\n<h3 id=\"redirect-to-www-using-htaccess-redirect\"><strong>Redirect to www using <\/strong>htaccess redirect<\/h3>\n<p>Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com<br \/>\nThe .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)<\/p>\n<pre class=\"lang:default decode:true\">Options +FollowSymlinks\r\nRewriteEngine on\r\nrewritecond %{http_host} ^domain.com [nc]\r\nrewriterule ^(.*)$ http:\/\/www.domain.com\/$1 [r=301,nc]<\/pre>\n<p>Please REPLACE domain.com and www.newdomain.com with your actual domain name.<\/p>\n<p><strong>Note*<\/strong> This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.<\/p>\n<h3 id=\"how-to-redirect-html\"><strong>How to Redirect HTML<\/strong><\/h3>\n<p>Please refer to section titled \u2018How to Redirect with htaccess\u2019, if your site is hosted on a Linux Server and \u2018IIS Redirect\u2019, if your site is hosted on a Windows Server.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A 301 Redirect is the most efficient and Search Engine Friendly method for webpage redirection. It\u2019s not that hard to implement and it should preserve your search engine rankings for&hellip;<\/p>\n","protected":false},"author":7,"featured_media":2963,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[35],"tags":[38,39,41,40,42,37,36],"powerkit_post_featured":[],"class_list":{"0":"post-2958","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-seo","8":"tag-asp-net-redirect","9":"tag-asp-redirect","10":"tag-coldfusion-redirect","11":"tag-iis-redirect","12":"tag-redirect-old-domain","13":"tag-redirect-websit","14":"tag-seo"},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/SEO.jpg?fit=1402%2C1355&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8NAi4-LI","jetpack-related-posts":[{"id":4173,"url":"https:\/\/code4developers.com\/net-framework-4-8-released\/","url_meta":{"origin":2958,"position":0},"title":".NET Framework 4.8 Released","author":"Arif Khoja","date":"April 27, 2019","format":false,"excerpt":"Microsoft has announced the release of the .NET Framework 4.8 that builds on previous versions of the .NET Framework 4.x by adding many new fixes and several new features while remaining a very stable product. Source: Microsoft According to the company .NET Framework 4.8 is included in the Windows 10\u2026","rel":"","context":"In &quot;News&quot;","block_context":{"text":"News","link":"https:\/\/code4developers.com\/category\/news\/"},"img":{"alt_text":"net_framwork","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2019\/04\/net_framwork_400.jpg?fit=400%2C400&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3544,"url":"https:\/\/code4developers.com\/angular-6-crud-part-1-project-setup-routing-service\/","url_meta":{"origin":2958,"position":1},"title":"Angular 6 CRUD \u2013 Part 1: Project Setup, Routing, Service","author":"Nisarg Dave","date":"May 9, 2018","format":false,"excerpt":"This article is Part 1 Angular 6 CRUD. In this article and upcoming article, we will discuss performing CRUD operations in Angular 6 i.e. Creating, Reading, Updating and Deleting in Angular 6 with simple examples. We will also discuss about the Angular 6 Project setup, apply Routing, create service to\u2026","rel":"","context":"In &quot;Angular&quot;","block_context":{"text":"Angular","link":"https:\/\/code4developers.com\/category\/angular\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/05\/json-server-call-300x297.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3824,"url":"https:\/\/code4developers.com\/restful-api-best-practices\/","url_meta":{"origin":2958,"position":2},"title":"RESTful API best practices and Designing guidelines\u200a","author":"Arif Khoja","date":"July 5, 2018","format":false,"excerpt":"Facebook, Google, Github, Netflix and few other tech giants have given a chance to the developers and products to consume their data through APIs, and became a platform for them. Even if you are not writing RESTful API for other developers and products, it is always very healthy for your\u2026","rel":"","context":"In &quot;Web Services&quot;","block_context":{"text":"Web Services","link":"https:\/\/code4developers.com\/category\/web-services\/"},"img":{"alt_text":"rest_api","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/07\/rest_api.png?fit=406%2C430&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3081,"url":"https:\/\/code4developers.com\/how-to-create-google-analytics-account\/","url_meta":{"origin":2958,"position":3},"title":"How to create Google Analytics account and Track Website?","author":"Jaymin Prajapati","date":"August 26, 2017","format":false,"excerpt":"For creating Google Analytics account follow the steps listed below. If you have google account the sign-in to it or else create a new one. After succesfull creation of account login with google account credential into below link. https:\/\/analytics.google.com After you have signed-in you need to sign-up for google analytics.\u2026","rel":"","context":"In &quot;SEO&quot;","block_context":{"text":"SEO","link":"https:\/\/code4developers.com\/category\/seo\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/SEO.jpg?fit=1200%2C1160&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/SEO.jpg?fit=1200%2C1160&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/SEO.jpg?fit=1200%2C1160&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/SEO.jpg?fit=1200%2C1160&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/07\/SEO.jpg?fit=1200%2C1160&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3165,"url":"https:\/\/code4developers.com\/pug\/","url_meta":{"origin":2958,"position":4},"title":"Pug","author":"Arif Khoja","date":"December 15, 2017","format":false,"excerpt":"Pug is a template language for Javascript that I have grown to enjoy a lot. My impression is that a lot of people use it, if they use a template engine for server side rendering using Node. The big question is if you need it or not in 2017. I\u2026","rel":"","context":"In \"Node\"","block_context":{"text":"Node","link":"https:\/\/code4developers.com\/tag\/node\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/12\/PugJs.png?fit=225%2C225&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3119,"url":"https:\/\/code4developers.com\/difference-between-javascript-and-ecmascript\/","url_meta":{"origin":2958,"position":5},"title":"What\u2019s the difference between JavaScript and ECMAScript?","author":"Arif Khoja","date":"October 31, 2017","format":false,"excerpt":"I\u2019ve tried googling \u201cthe difference between JavaScript and ECMAScript.\u201d I ended up having to wade through a sea of ambiguous and seemingly conflicting results: \u201cECMAScript is a standard.\u201d \u201cJavaScript is a standard.\u201d \u201cECMAScript is a specification.\u201d \u201cJavaScript is an implementation of the ECMAScript standard.\u201d \u201cECMAScript is standardized JavaScript.\u201d \u201cECMAScript is\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/code4developers.com\/category\/javascript\/"},"img":{"alt_text":"javascript","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/10\/javascript.jpg?fit=750%2C422&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/10\/javascript.jpg?fit=750%2C422&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/10\/javascript.jpg?fit=750%2C422&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/10\/javascript.jpg?fit=750%2C422&ssl=1&resize=700%2C400 2x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/posts\/2958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/comments?post=2958"}],"version-history":[{"count":6,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/posts\/2958\/revisions"}],"predecessor-version":[{"id":2966,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/posts\/2958\/revisions\/2966"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/media\/2963"}],"wp:attachment":[{"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/media?parent=2958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/categories?post=2958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/tags?post=2958"},{"taxonomy":"powerkit_post_featured","embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/powerkit_post_featured?post=2958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}