{"id":304,"date":"2009-05-01T19:01:01","date_gmt":"2009-05-01T13:01:01","guid":{"rendered":"http:\/\/techsatwork.com\/blog\/?p=304"},"modified":"2016-01-07T11:31:13","modified_gmt":"2016-01-07T05:31:13","slug":"redirecting-your-url","status":"publish","type":"post","link":"https:\/\/techsatwork.com\/?p=304","title":{"rendered":"Redirecting your URL"},"content":{"rendered":"<p>Couple of blogs I follow was discussing about URL shorteners and its pros and cons. While I wonder about it, I was thinking why would you need URL shorteners when you can easily use 301 Redirect to create your own and still be search engine friendly and even more have total control of your site. \u00c2\u00a0Some of the url shorteners out there put banner ads or splash ads which I hate , but 301 redirect avoids all that. \u00c2\u00a0 Its the\u00c2\u00a0most efficient \u00c2\u00a0method for webpage redirection and preserves your page ranking and is search engine friendly. \u00c2\u00a0Its very easy to implement . \u00c2\u00a0The code &#8220;301&#8221; is interpreted as &#8220;moved permanently&#8221;.<\/p>\n<p class=\"defaultfont\" align=\"justify\">There are few ways to implement the 301 URL redirection :\u00c2\u00a0<\/p>\n<p class=\"defaultfont\" align=\"justify\">Save one of the code onto a file with appropriate extension and upload it your hosting site .<\/p>\n<h2>Redirect using PHP<\/h2>\n<p><span class=\"defaultfont\">&lt;?php<br \/>\nHeader( &#8220;HTTP\/1.1 301 Moved Permanently&#8221; );\u00c2\u00a0<br \/>\nHeader( &#8220;Location: http:\/\/www.new-url-location.com&#8221; );\u00c2\u00a0<br \/>\n?&gt;\u00c2\u00a0<\/span><\/p>\n<h2>Redirect using ASP<\/h2>\n<p><span class=\"defaultfont\">&lt;%@ Language=VBScript %&gt;<br \/>\n&lt;%<br \/>\nResponse.Status=&#8221;301 Moved Permanently&#8221;<br \/>\nResponse.AddHeader &#8220;Location&#8221;,&#8221;http:\/\/www.new-url-location.com\/&#8221;<br \/>\n%&gt;\u00c2\u00a0<\/span><\/p>\n<h2><span class=\"defaultfont\"><strong>Redirect using ASP.NET<\/strong><\/span><\/h2>\n<p><span class=\"defaultfont\">&lt;script runat=&#8221;server&#8221;&gt;<br \/>\nprivate void Page_Load(object sender, System.EventArgs e)<br \/>\n{<br \/>\nResponse.Status = &#8220;301 Moved Permanently&#8221;;<br \/>\nResponse.AddHeader(&#8220;Location&#8221;,&#8221;http:\/\/www.new-url-location.com\/&#8221;);<br \/>\n}<br \/>\n&lt;\/script&gt;\u00c2\u00a0<\/span><\/p>\n<h2>Redirect using JSP<\/h2>\n<p><span class=\"defaultfont\">&lt;%<br \/>\nresponse.setStatus(301);<br \/>\nresponse.setHeader( &#8220;Location&#8221;, &#8220;http:\/\/www.new-url-location.com\/&#8221; );<br \/>\nresponse.setHeader( &#8220;Connection&#8221;, &#8220;close&#8221; );<br \/>\n%&gt;\u00c2\u00a0<\/span><\/p>\n<h2>Redirect using CGI Perl<\/h2>\n<p><span class=\"defaultfont\">$q = new CGI;<br \/>\nprint $q-&gt;redirect(&#8220;http:\/\/www.new-url-location.com\/&#8221;);\u00c2\u00a0<\/span><\/p>\n<p><span class=\"defaultfont\"><br \/>\n<\/span><\/p>\n<h2>Ruby on Rails Redirect<\/h2>\n<p><span class=\"defaultfont\">def old_action<br \/>\nheaders[&#8220;Status&#8221;] = &#8220;301 Moved Permanently&#8221;<br \/>\nredirect_to &#8220;http:\/\/www.www.new-url-location.com\/&#8221;<br \/>\nend\u00c2\u00a0<\/span><\/p>\n<h2><strong>Redirect by configuring IIS<\/strong><\/h2>\n<p>\u00c2\u00a0<\/p>\n<ul class=\"defaultfont\">\n<li>In internet services manager, right click on the file or folder you wish to redirect<\/li>\n<li>Select the radio titled &#8220;a redirection to a URL&#8221;.<\/li>\n<li>Enter the redirection page<\/li>\n<li>Check &#8220;The exact url entered above&#8221; and the &#8220;A permanent redirection for this resource&#8221;<\/li>\n<li>Click on &#8216;Apply&#8217;<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Couple of blogs I follow was discussing about URL shorteners and its pros and cons. While I wonder about it, I was thinking why would you need URL shorteners when you can easily use 301 Redirect to create your own and still be search engine friendly and even more have total control of your site. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","site-transparent-header":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[156,1],"tags":[161,157,163,164,160,159,167,162,158,166,165],"class_list":["post-304","post","type-post","status-publish","format-standard","hentry","category-internet","category-misc","tag-301-moved-permanently","tag-301-redirect","tag-asp-redirect","tag-aspnet-redirect","tag-cgi-perl-redirect","tag-jsp-redirect","tag-moved-permanently","tag-php-redirect","tag-url-redirect","tag-url-shortners","tag-website-redirect"],"_links":{"self":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=304"}],"version-history":[{"count":4,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/304\/revisions"}],"predecessor-version":[{"id":308,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/304\/revisions\/308"}],"wp:attachment":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}