Many have heard about the 301 redirect more than once. But due to the lack of need for it, and also because of the fear of doing something wrong, they did not attach importance to such a procedure. The article will discuss in detail how to configure 301 redirects.
About its configuration, you can find more than a dozen articles and informational materials. But after viewing many of them, novice computer users and webmasters may have difficulty understanding the basics of customization. Numerous codes and scripts provided in online sources of information, for the most part, cause misunderstanding. In reality, everything is much simpler, and this article will serve as a good guide on how to set up 301 redirects.
What is 301 redirect?
. 301. () . , - , , -.
301 - .htaccess
, .htaccess. 301 . Htaccess , . , , , 301 .
. . .htaccess. .
.htaccess
, . – FTP-. - FileZilla.
- - – " " – .htaccess – OK. . .
, FTP- , .htaccess. , , . . “” .
, .htaccess, 301 . , .
, 301
-, 301 . , , , www, .
, www . . - robots.txt Host. , ".". , 301 . "" .
- . - , , .
. , . , SEO- - .
www - . www . www – . - www. . , . , 301, , - .
301 , . , . .
www , . , - , . .
- , -. , . : www, www ( ).
. , . , www, . .
, .htaccess. 301, , www .
www
. . .htaccess .
www :
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.moydomen.com
RewriteRule ^(.*)$ http://moydomen.com/$1 [R=301,L].
-:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^moydomen.com
RewriteRule (.*) http://www.moydomen.com/$1 [R=301,L].
, moydomen.com - !
.htaccess . ( http, , www, ), . , 301 www www. .
-
, , - . . , moysait-1.com moysait-2.com. .htaccess :
RewriteEngine On
RewriteCond %{HTTP_HOST} moysait-1.com
RewriteRule (.*) http://moysait-2.com/$1 [R=301,L].
. , , . , . . 301 ? , , (, ), .
. moya_infa.html obo_mne.html. .htaccess : redirect 301 moya_infa.html http://www.moydomen.com/obo_mne.html.
301 .
. - moya_stranichka.html moya_stranichka.php. , .htaccess : redirect 301 moya_stranichka.html http://www.moydomen.com/moya_stranichka.php.
, . www.partner.com/?ref=16011. , , .
, dlya_druzei.html, . .htaccess: redirect 301 dlya_druzei.html http://www.partner.com/?ref=16011.
, 301 Joomla PHP.
301 CMS Joomla
404. Joomla . . . 301. Joomla .htaccess, , .
-. , htaccess.txt .htaccess. (SEF) URL.
.htaccess .
PHP
- .htaccess , - 301. PHP .
, .php, index :
<?$ref=$_SERVER['QUERY_STRING'];
if ($ref!='') $ref='?'.$ref;header('HTTP/1.1 301 Moved Permanently');
header('Location: http://moydomain.ru/'.$ref);
exit();
?>.
moydomain.ru , . .
, :
<?php;
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.moydomain.ru/moycategory/moypage.htm");
exit();
?>.
www.moydomain.ru/moycategory/moypage.htm , .
, , , .php. .htaccess.
, , , 301, . . . , , .
, .htaccess, CMS, PHP.