{"id":653,"date":"2017-04-05T09:51:38","date_gmt":"2017-04-05T09:51:38","guid":{"rendered":"http:\/\/graphenelive.in\/?p=653"},"modified":"2017-04-05T09:51:38","modified_gmt":"2017-04-05T09:51:38","slug":"ultimate-guide-301-redirects","status":"publish","type":"post","link":"http:\/\/graphenelive.in\/ultimate-guide-301-redirects\/","title":{"rendered":"Ultimate guide for 301 Redirects"},"content":{"rendered":"
Response code 301 (Moved Permanently) indicates that the requested document is now available at the new address on an ongoing basis. 301 redirects can be necessary in a few cases: the move to the new domain address change page or gluing mirrors site . The objectives of these events are quite clear:<\/p>\n
There are several ways to make a 301 redirect, but I prefer the option of using .htaccess file, which is located in the root directory of your FTP site (if it’s not there, just create it, it has no extension).<\/p>\n
Quite often a situation arises when a site page has been deleted or is forced to change its URL. When referring to her old address, the user itself, see page 404 (not found).Here’s the syntax:<\/p>\n
\nRedirect 301 \/old-page.html http:\/\/new-domain.com\/new-page.html\n<\/code><\/pre>\nWell or so, the result is the same:<\/p>\n
\nRedirect permanent \/old-page.html http:\/\/new-domain.com\/new-page.html\n<\/code><\/pre>\nMake no mistake: \/old-page.html – relative URL of the old page. It can be attached: \/old-category\/old-page.html, well, or so: \/ old-category \/ old-page \/ – there are no limits. The same applies to http:\/\/new-domain.com\/new-page.html (new page), with the only difference being that here the absolute path (not necessarily that it was new domain – may just be a new internal address of the page ).<\/p>\n
Setting up 301 redirects when moving a site to a new domain<\/p>\n
No less clear the situation. There was a need to move to a new domain, keep the old, in this case, the attribute of the old domain .htaccess following:<\/p>\n
\n\n\n+ FollowSymLinks the Options\n\nRewriteEngine on\n\n<FilesMatch \"$ a robots.txt\">\n\nRewriteEngine off\n\n \n\nRewriteCond% {} ^ HTTP_HOST old-domain \\ .mobi\n\nthe RewriteRule ^ (. *) $ Http:\/\/new-domain.com\/$1 [R = 301, L]\n\nRewriteCond% HTTP_HOST} ^ {www.oldsite \\ .com\n\nRewriteRule ^ (. *) $ http:\/\/old-domain.com\/$1 [R = 301, L]\n\n<\/code><\/pre>\nIn this example, we set the redirect all pages of the old domain to the new page (provided that the relative addresses are the same). <\/p>\n
Edit the robots.txt in old domain as below.<\/p>\n
\n\nAgent-the User: *\n\nDisallow: \/\n\n<\/code><\/pre>\n301 domain redirect without www with at www:<\/p>\n
\n\n+ FollowSymLinks Options\n\nRewriteEngine On\n\n<FilesMatch \"robots.txt $\">\n\nRewriteEngine off\n\n \n\nRewriteCond% HTTP_HOST {^} $ site.ru\n\nRewriteRule (. *) Http:\/\/www.site.com\/$1 [R = 301 , L]\nThe reverse situation - with no on www www:\n\n+ FollowSymLinks Options\n\nRewriteEngine On\n\n<FilesMatch \"robots.txt $\">\n\nRewriteEngine off\n\n \n\nRewriteCond% HTTP_HOST {^} $ www.site.com\n\nRewriteRule (. *) Http:\/\/site.com\/$1 [R = 301 , L]\n\n<\/code><\/pre>\nAfter editing, save the file and upload it to the root folder of the FTP by overwriting.<\/p>\n","protected":false},"excerpt":{"rendered":"
Response code 301 (Moved Permanently) indicates that the requested document is now available at the new address on an ongoing basis. 301 redirects can be necessary in a few cases: the move to the new domain address change page or gluing mirrors site . The objectives of these events are quite clear: Transferring old records<\/p>\n","protected":false},"author":1,"featured_media":655,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[92,107],"tags":[106,108,109],"_links":{"self":[{"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/posts\/653"}],"collection":[{"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/comments?post=653"}],"version-history":[{"count":0,"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/posts\/653\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/media\/655"}],"wp:attachment":[{"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/media?parent=653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/categories?post=653"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/graphenelive.in\/wp-json\/wp\/v2\/tags?post=653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}