301 редирект htaccess генератор

REDIRECT GENERATORS

301 REDIRECT

What is it and how to choose the right tool?

What is the 301 redirect?

It is special information (code) sent to the browser or search bot by your server on a certain page visit. The code means moved permanently.

How to choose a right generator for a permanent redirect?

If your server is Apache and You have access to the configuaration file You may need to choose RewriteRule or RedirectMatch generators. Use RedirectMatch generator only if already have a lot of such redirects you need to keep. In case You have access to PHP files only You can choose our PHP generator.

Why should I use redirections?

To keep your site searchable by search engines like Google you need to apply 301 redirect to old pages after url change. Without this information search bots can’t understand (in most of the cases) that page url was changed, but the content is the same and valuable for to be visible in search results. If your income depends on organic search, there is a very special reason to do redirects in the right way. So, if you decided to change your domain or just rename page url you need to make redirects. One of our code generation tools may help you in such situations.

When should I apply a permanent redirect?

«Redirect» vs «RewriteRule»

WordPress

Maybe, most popular server for WordPress is Apache. While many SEO plugins provide a possibility to add and manage PHP redirects in WordPress admin panel, we can’t suggest using permanent redirect WordPress plugins because Apache redirects are much faster and, therefore, better for user experience and for SEO in many cases. Some plugins can work with Apache configuration file directly, but it is a less secure approach, so, better to use other methods.

Источник

Создание htaccess для сайта

по промокоду IKSWEB

по промокоду IKSYAR

Бесплатно с поддержкой!

При создании файла Hypertext Access обычно возникают проблемы, которые не дают работать сайту. Большинство ошибок возникает из-за лишних пробелов или отсутствия нужных запятых. По этой причине я решил сделать инструмент, который поможет всем без знаний основ по настройке серверов, создать правильный htaccess для любой CMS.

.htaccess (от англ. hypertext access) — файл дополнительной конфигурации веб-сервера Apache, а также подобных ему серверов. Позволяет задавать большое количество дополнительных параметров и разрешений для работы веб-сервера в отдельных каталогах.

Дополнительные варианты перенаправлений

Редирект всех страниц с http:// на https://, в том числе и с http://www на https://

Вариант 1

Вариант 2

Вариант 3

Вариант 4

Редирект с домена с WWW на домен без WWW

RewriteEngine On
RewriteCond % ^www.site.ru$ [NC]
RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L]

Редирект с домена без WWW на домен с WWW

RewriteEngine On
RewriteCond % ^site.ru
RewriteRule (.*) http://www.site.ru/$1 [R=301,L]

Настройка 301 редиректа для сайта

Единственная функция где могут возникнуть проблемы у пользователей. Поэтому я решил описать подробную инструкции. Если вы выполните последовательность, описанную ниже, вы сможете выполнить настройку редиректов правильно.

Возможности инструмента

Функционал инструмента включает только самые полезные настройки, которыми пользуюсь сам.

Источник

.HtAccess 301 Redirect Code Generator Tool

Contents

Setting up 301 redirects is a common SEO activity to fix broken link problems or to do a site move. This online tool helps you create those redirects on the popular Apache server used by most hosting providers. CMS systems like WordPress, Joomla and Magento are normally on this type of server.

An .htaccess file is a file on Apache servers used for several things including controlling how different URLs are processed. One common use is when a website is re-written and you want to forward all the users visiting your old pages to the new ones.

In the .htaccess file, this is done by adding RewriteRules that cause 301 Redirects from one page to another. The 301 Permanent Redirect is the best way to perform forwarding as it also tells the Search Engines to update their indexes.

Читайте также:  centos 7 удалить php полностью

Manually creating these RewriteRules can be time consuming and error prone. This tool will generate the rules for you.

Not using Apache?
Then check out my article on how to do 301 redirects, which covers examples for other servers and languages.

Enter a comma or tab separated lists of old to new pages then click the generate button. Copy the resulting code into your .htaccess file then see if the pages are redirecting as expected.

I find the simplest way to do this is to create an Excel file with two columns. Place the old pages in the first column and the new pages in the second column. Then just copy and paste the cells into the form below.

You only need to enter the path for each page and not the whole URL. e.g. about-us.htm. Just using paths means the rules generated are domain name independent. If you enter the full URL then the code generated will also take the domain into account. This way you can have the rule only apply to a single domain or have the redirect switch to a different domain.

Want to test your Redirects?
Then use my Redirect Header Checker Tool to see what’s happening.

An example list may look like this:

index.php?page=45, contact-us/
about-us.htm, about-us/
product-details.php?id=345, product/345/?view=details

Here’s an overview on what it does

For each rule there may be conditions that must be met before a rewrite rule is considered. These Rewrite Conditions are added using the RewriteCond command. The above one is used if the old path included a specific domain (HTTP_HOST) to use.

Dynamic URLs contain querystring parameters after a question mark (?). These have to be specified as a rewrite condition (QUERY_STRING). If no querystring is used then a blank rewrite condition is added to make sure it only matches URLs without query strings.The condition is written using Regular Expression (Regex) syntax.

Some Regex Basics

^ The start of a string
$ The end of a string
\. Dots need escaping with a slash as they have a meaning (any character)
\+ Plus needs escaping with a slash as it means «one or more» of the previous character

The above rewrite condition is added if the old path specifically used https:// in its URL, thus stating it’s secure.

RewriteRule ^about-us\.htm$ /about-us/? [R=301,NE,NC,L]

Then the actual RewriteRule. This first states the path that must be matched for the rewrite rule to be used (once all the previous rewrite conditions are met). This is in a Regular Expression (Regex) syntax.

The generator creates a Regex string that enforces an exact match with the supplied path.

Next we add the page we are Permanently Redirecting to. This may be a relative path or a complete URL, depending on the format used in the original list. If the URL does not contain a question mark (?) then one is added. This is a signal to stop the querystring from the old page being added.

Finally a set of flags are included to define how the rewrite rule works. They specify it should be a 301 Permanent Redirect (R=301), the URL should not be escaped (NE), it should not be case sensitive (NC) and it is the last rule that needs to be processed (L).

SEO Consultation Services
Amongst other things I offer Technical SEO Support at a Very Reasonable Rate.
More Info.

Why don’t I use the shorter Redirect command

There is a lot simpler Redirect command that can do redirects in one line. e.g.

Redirect 301 /testsource.html /testdestination.html?a=b

The main reason I don’t use it is because my tool is designed to do exact URL redirecting. The Redirect command does not consider incoming query strings which means an exact source match can’t be done. e.g. the above command will also match /testsource.html?parameter=value

Читайте также:  на листьях клубники мелкие дырочки что делать

Another limitation is that you can’t restrict the source to a specific domain. However you can specify the domain of the destination, and specify a query string (any source query string is always ignored and lost).

What if I have lots of 301 redirects!

Another option is to use Apache RewriteMap. It is quite technical but it allows you to create lookup tables and therefore will scale better than the basic RewriteRule commends. The maps need to be added at the server level which means this is not an option for those using shared hosting or with limited control of their servers.

Can I help you improve the tool?

About Tony McCreath

I set up Web Site Advantage at the start of 2010 in order to fully focus on internet marketing and building my clients businesses online.

I like to write tools and guides to help people do their jobs more efficiently. I’m also very active in helping out in forums and Q&A sites. I’m a Gold Product Expert in the Google Webmasters Help Community. I’m also the creator of Classy Schema.

Источник

How to use online Apache htaccess rewrite generator

Url preparation for mod rewrite htaccess generator

Write down your old and new urls in some table like Google sheets. Use only correct urls with «http» or «https» or just relevant without domain name.

Mark, copy and paste both columns into the first field of redirect htaccess generator. Spaces between the urls and line breaks will be inserted automatically.

Also, you can use any text editor to prepare urls, but be careful with line breaks.

How to choose a separator for urls

Spaces, commas and semicolons can be a part of urls. This tool does not support automatic CSV format recognition and escaping. If You have such a symbol in urls, You will need to choose another separator in your CSV data and htaccess mod rewrite generator options to avoid problems with the generation of rewrite rules.

Tips for htaccess redirect generator

Do I need to strip host name on permanent redirect htaccess code generation

By default «delete old host names» option is selected and schema, domain check skipped. If You need a more flexible solution for further usage on other hosts, staging or testing environments, there is an option to strip new host name also. But, if you need to be sure that rules be applied exactly, with conditions on certain hosts, better not to strip.

How to handle query strings on redirect (htaccess redirect url containing string)

The most common situation is when You replacing urls containing query strings with urls without query strings. This is why the default action with query strings is to skip ones. Also possible to add query string to new url or to combine old and new query strings. You will need to select the appropriate htaccess rewrite rule generator option.

What does «Query strings match policy» mean?

The reason for not to escape new urls on redirection

In rare cases, if your valid new url contains special chars like «#»(%23), you may need to choose an option «Do not escape new urls» in order to obtain good results after redirect.

Order of rewrite rules in htaccess redirect code

First of all, do not insert the code inside common code block generated by WordPress, Joomla, or other CMS, because this way the code can be overwritten after CMS update. Place the code at the begging of the file or where other already working redirects located.

Why not use «Redirect 301» directives

«Redirect 301» or «Redirect permanent» are directives of mod Alias, while this mod rewrite generator uses RewriteCond, RewriteRule. There are a lot of reasons for not to use «Redirect 301». It can’t do checks and operations with query strings. It can’t check domain names. It will redirect whole directories, but not individual urls. Finally, It has a separate flow. If you have a lot of mod_alias Redirect or RedirectMatch rules, please, use mod Alias page to page RedirectMatch generator or rebuild your old rules with mod rewrite.

Читайте также:  практика психолога в мвд отчет

I need more, not just page to page redirection. Where can I find more directions?

You can contact us directly or You can use Apache documentation. More about mod_rewrite here.

Источник

Как сделать 301 редирект (переадресацию) через htaccess

Редирект (перенаправление или форвардинг) —позволяет автоматически переадресовать пользователя, посетившего страницу А на страницу Б. Например, пользователь, пытающийся открыть страницу site.ru/page1/ будет попадать на site.ru/page2.

Как сделать редирект через файл htaccess

Для того, чтобы перенаправить пользователя с одной страницы на другую требуется использовать следующую комбинацию:

Redirect 301 site.ru/page1/ site.ru/page2/

Важно! Можно записывать адреса в относительном виде, например, /page1/ и /page2/.

Также допускается использование конструкции:

Redirect permanent site.ru/page1/ site.ru/page2/

Для того, чтобы выполнить правило, потребуется посетить административную панель хостинга (или же зайти через FTP), где в корневой папке сайта лежит файл htaccess.

Вводим нужное нам правило.

Как проверить работу 301 редиректа?

Для этого можно использовать инструмент проверки ответа сервера Яндекса:

Здесь вводим адрес первой страницы и видим следующее:

Как видим правило применилось и работает корректно.

Как сделать перенаправление на другой домен?

В этом случае необходимо автоматически перекидывать всех пользователей с домена domain1.ru на domain2.ru при помощи функции:

RewriteRule ^(.*)$ http://www.domain2/$1 [R=301,L]

Переадресация с http на https

При переезде сайта с http на https (установка SSL-сертификата) потребуется код, который не требует дополнительных модификаций:

Второй метод осуществляет перенос с http://domain.ru на https://domain.ru:

RewriteRule ^(.*)$ https://domain.ru/$1 [R=301,L]

Третий способ выполняет аналогичную функцию, но отключает перенаправление для robots.txt:

RewriteRule ^(.*)$ https://domain.ru/$1 [R=301,L]

В 4-й версии конечным пунктом для пользователя станет https://www.domain.ru:

RewriteRule ^(.*)$ https://www.domain.ru/$1 [R=301,L]

Позволяет сделать форвардинг с http://www.poddomen.domain.ru на https://poddomen.domain.ru:

RewriteCond % ^www\.poddomen\.domain\.ru$ [NC]

RewriteRule ^(.*)$ https://poddomen.domain.ru/$1 [R=301,L]

Последняя версия, дающая возможность сделать связь между http://poddomen.domain.ru на https://www.poddomen.domain.ru:

RewriteCond % ^poddomen\.domain\.ru$ [NC]

RewriteRule ^(.*)$ https://www.poddomain.domain.ru/$1 [R=301,L]

301 редирект с домена без WWW на с WWW

В функции ниже осуществляется переход из www.poddomen.domain.ru на poddomen.domain.ru:

RewriteCond % ^www\.poddomen\.domain\.ru$ [NC]

RewriteRule ^(.*)$ http://poddomen.domain.ru/$1 [R=301,L]

Если же первый способ не помог можно использовать данную версию:

RewriteCond % !^poddomen\.domain\.ru$ [NC]

RewriteRule ^(.*)$ http://poddomen.domain.ru/$1 [R=301,L]

С www на без WWW

RewriteCond % ^poddomen\.domain\.ru$ [NC]

RewriteRule ^(.*)$ http://www.poddomen.domain.ru/$1 [R=301,L]

Также имеется второй метод не требующий ввода доменного имени:

C https на http

При необходимости сделать обратную интеграцию и перейти на незащищенную версию протокола можно воспользоваться:

301 редирект на http для одной страницы

В этой ситуации подойдет:

Второй метод осуществляет общий переезд на защищенный протокол (https), но одна страница останется на старом протоколе (http). Этот способ подойдет для интеграции 1С Bitrix с 1С Предприятие, так как система не может работать с защищенным протоколом:

Для готовой интеграции с 1С-Битрикс, формула позволяющая исключить директорию bitrix/admin/1c_exchange.php из общего правила:

RewriteCond % !^/bitrix/admin/1c_exchange\.php$ [NC]

Форвардинг на https для конкретной страницы

Для этой цели можно воспользоваться:

RewriteCond % ^/Необходимая директория_страница$

С несуществующего файла

В этом случае можно будет применить:

RewriteRule ^(.*)$ /poddomen/script.php [R=301,L]

Также подойдет второй способ:

RewriteCond % !^poddomen\.domain\.ru$ [NC]

RewriteRule ^(.*)$ http://poddomen.domain.ru/$1 [R=301,L]

Перенаправление на подкаталог

В этом случае возможно пербрасывать пользователей с poddomen.domain.ru на подкаталог poddomen.

RewriteEngine on
RewriteBase /
RewriteCond % !^/poddomen
RewriteCond % ^poddomen.domain.ru$ [NC]
RewriteRule ^index.php(.*)$ /poddomen/$1 [L,QSA]

RewriteEngine on
RewriteBase /
RewriteCond % ^poddomen.domain.ru$
RewriteCond % !/poddomen/
RewriteRule ^(.*)$ /poddomen/$1 [L]

В случае, когда речь идет о www.poddomen.doamin.ru необходимо применить:

RewriteRule ^(.*)$ /poddomen/$1 [L]

С любой страницы на главную

RewriteRule ^(.*)$ index.php [L,QSA]

С поддомена на основной домен

Если требуется выполнить условие для всех поддоменов без исключения:

RewriteCond % ^(.+).domain.ru$
RewriteRule (.*) http://site.ru/$1?region=%1 [L,R=301,QSA]

Когда речь идет о конкретном поддомене следует использовать:

Источник

Образовательный портал