- April 5, 2017
- Posted by: admin
- Category: Blogging, Hosting
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 to a new page or domain.
- Elimination of broken links, both external and internal.
- Elimination of duplicate pages.
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).
Setting 301 redirect from one page
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:
Redirect 301 /old-page.html http://new-domain.com/new-page.html
Well or so, the result is the same:
Redirect permanent /old-page.html http://new-domain.com/new-page.html
Make 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 ).
Setting up 301 redirects when moving a site to a new domain
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:
+ FollowSymLinks the Options
RewriteEngine on
<FilesMatch "$ a robots.txt">
RewriteEngine off
RewriteCond% {} ^ HTTP_HOST old-domain \ .mobi
the RewriteRule ^ (. *) $ Http://new-domain.com/$1 [R = 301, L]
RewriteCond% HTTP_HOST} ^ {www.oldsite \ .com
RewriteRule ^ (. *) $ http://old-domain.com/$1 [R = 301, L]
In this example, we set the redirect all pages of the old domain to the new page (provided that the relative addresses are the same).
Edit the robots.txt in old domain as below.
Agent-the User: *
Disallow: /
301 domain redirect without www with at www:
+ FollowSymLinks Options
RewriteEngine On
<FilesMatch "robots.txt $">
RewriteEngine off
RewriteCond% HTTP_HOST {^} $ site.ru
RewriteRule (. *) Http://www.site.com/$1 [R = 301 , L]
The reverse situation - with no on www www:
+ FollowSymLinks Options
RewriteEngine On
<FilesMatch "robots.txt $">
RewriteEngine off
RewriteCond% HTTP_HOST {^} $ www.site.com
RewriteRule (. *) Http://site.com/$1 [R = 301 , L]
After editing, save the file and upload it to the root folder of the FTP by overwriting.