Как сделать редирект cloudflare
Cloudflare Help Center
Articles in this section
Connect with the Cloudflare Community
More on this topic: Discussions and Tips
Connect with the Cloudflare Community
Configuring URL forwarding or redirects with Cloudflare Page Rules
Learn how to set up URL forwarding or redirects with Cloudflare.
Overview
You can define a page rule to forward or redirect traffic to a different URL using the Rules app in the Cloudflare dashboard.
Forwarding examples
Imagine you want site visitors to easily reach your website for a variety of URL patterns. For instance, the Page Rule URL patterns *www.example.com/products and *example.com/products match:
but do not match: Once you have created the pattern that matches what you want, click the Forwarding toggle. That exposes a field where you can enter the address I want requests forwarded to. If I enter the address above in the forwarding box and click Add Rule, within a few seconds any requests that match the pattern I entered will automatically be forwarded with a 302 Redirect to the new URL.
Advanced forwarding options
If you use a basic redirect, such as forwarding the root domain to www.example.com, then you lose anything else in the URL.
To fix the forwarding from the root to www in the above example, you could use the same pattern: You’d then set up the following URL for traffic to forward to: In this case, if someone went to: They’d be redirected to:
Как перенаправить один домен на другой без хостинга?
Если у вас нет тарифного плана хостинга и Вы хотите перенаправить свой домен на другой домен, это легко сделать с помощью Cloudflare.
Зарегистрируйтесь в Cloudflare и добавьте Ваш домен в аккаунт. В результате Вы получите имена серверов, которые пригодятся нам дальше.
В аккаунте Hostinger перейдите в Панель управления доменом:
Вам нужны эти записи:
После того, как Вы укажете новые NS записи, запустится процесс делегирования DNS зоны, который может занимать до 48 часов (но чаще всего занимает намного меньше). Процесс полностью автоматический, Вы можете следить за прогрессом на этой странице.
Как только домен полностью делегируется, можно будет создать перенаправление. Для этого:
1. Авторизуйтесь в Cloudflare аккаунте;
2. Откройте страницу Page Rules и нажмите Create Page Rule
3. В пункте If the URL matches задайте точную ссылку, при переходе на которую должно срабатывать перенаправление:
Нажмите Add a Setting:
Выберите из списка Forwarding URL, укажите тип перенаправления (301 для постоянного, 302 для временного) и внесите ссылку, на которую должно быть перенаправление:
4. Сохраните изменения (Save and Deploy). Поздравляем, Вы успешно создали перенаправление! Чтобы увидеть изменения может понадобится очистить кэш браузера и локальный DNS кэш 😊
Cloudflare Help Center
Articles in this section
Connect with the Cloudflare Community
More on this topic: Discussions and Tips
Connect with the Cloudflare Community
Understanding Cloudflare Mobile Redirect
Learn how Mobile Redirect optimizes the look and feel of your website for use on mobile devices.
Overview
Mobile Redirect allows you to automatically redirect mobile device visitors to a mobile-optimized website or subdomain home page. The redirect is done at the edge of Cloudflare’s network, improving the user experience by eliminating a roundtrip to your server.
You must have Cloudflare’s performance service enabled («orange clouded» in the DNS Settings) for the redirect to be active.
Enable Mobile Redirect
1. Log into your Cloudflare account.
2. Click the appropriate Cloudflare account for the domain where you want to enable Mobile Redirect.
3. Click the Speed app.
4. Click the Optimization tab.
5. Scroll down to the Mobile section of the Optimization tab.
6. Select the subdomain that you would like to redirect from the drop down list.
7. Choose Keep Path or Drop Path.
Compatible mobile devices
Browsers from the following mobile devices are redirected to the mobile-optimized subdomain:
Allow full site view
To allow your end users to view the full site on mobile, you’ll need to set the value of the following cookie on the root domain only to 0 (zero) at your origin server:
__cf_mob_redir = 0; domain=.example.com
To renew the mobile redirect, delete the cookie, or set it to expire after whatever duration you choose.
Cloudflare Help Center
Articles in this section
Connect with the Cloudflare Community
More on this topic: Discussions and Tips
Connect with the Cloudflare Community
3xx Redirection
Learn how to use 3xx codes to redirect the User-Agent.
Overview
3xx codes are a class of responses that suggest the User-Agent must follow another course of action to obtain the complete requested resource.
Redirect Location should be set in either:
Multiple options for the resource that the client may follow. For instance, it could be used to present different format options for video, list files with different extensions, or word sense disambiguation.
Permanent URL redirect for the resource requested. The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.
Cloudflare is able to generate these responses, thus avoiding the need to send a request to the origin server’s response through the use of Page rules. Read more How Cloudflare can help generate redirects at Page Rules URL Forwarding
Similar to a 301 redirect, but is intended for temporary purposes only. User-Agent may automatically follow the Location header, but should not replace the current URI with it as a 301.
Cloudflare is able to generate these responses, thus avoiding the need to send a request to the origin server’s response through the use of Page rules. Read more How Cloudflare can help generate redirects at Page Rules URL Forwarding
User-Agent should follow this redirect with a GET request. Note: differs from 301 in that the resource at the redirect is not necessarily equivalent to what was requested
Signal to the client that the requested resource is available and valid in the cache. The origin server has not modified the resource that the request inquired about. Client can receive the payload for the specified resource without connecting to the origin server again thus it is redirecting the request to use the stored resource. Requirements on a cache that receives a 304 response are defined in Section 4.3.4 of [RFC7234].
Prior to this response, the client sent a conditional GET or HEAD request specifying what resource it currently has stored. Server is giving the client the “OK” to use this resource as the most updated version in order to reduce the amount of data transmission between client and server.
When a request is made to Cloudflare that is stale so must be revalidated at the origin, Cloudflare will send a 304 response to confirm the version in our cache matched the version at origin. The response will include the CF-Cache-Status: REVALIDATED header. and Cloudflare confirms the version using the If-Modified-Since header. For more information see: ETag Headers
Request must be fulfilled through proxy URI specified in Location header instead of through the origin. This status code has been deprecated due to security risks.
Notification that following requests must come must be directed to the proxy specified.
A redirect similar to a 302 response except that the request method (e.g. GET, POST..) must not differ from what was used in the original request if automatically following the redirect.
Permanent redirect similar to a 301 except the request method (e.g. GET, POST..) must not differ from what was used in the original request if automatically following the redirect.
Как перенаправить домен без хостинга с помощью Cloudflare
Главное меню » Сетевые технологии » Как перенаправить домен без хостинга с помощью Cloudflare
Шаг 1: Создайте учетную запись на Cloudflare:
Все, что вам нужно сделать, это обратиться в службу поддержки, чтобы сменить серверы имен. Для вас важно знать и помнить, что распространение DNS может занять до 24 часов на этом этапе. Просто замените серверы имен и подождите день или два перед повторной проверкой.
Шаг 2: Используя Cloudflare, настройте перенаправление для своего домена:
Перед тем, как начать с этого шага, убедитесь, что ваш домен успешно работает после смены сервера имен. Если он действительно успешно сменился, вы можете продолжить настройку перенаправления для своего домена. Для этого откройте раздел Правила страницы в своей учетной записи Cloudflare и настройте правило, нажав кнопку «Создать правило страницы».
Теперь введите имя домена или конкретный IP-адрес, на который вы хотите перенаправить посетителя вашего домена. Вам нужно щелкнуть URL-адрес пересылки. Оказавшись там, вам будет предложено два варианта:
После того, как вы выбрали нужный вариант, добавьте URL-адрес целевой страницы.
Нажмите на кнопку «Сохранить и развернуть». Вот и все. Вы сделали. Теперь попробуйте ввести адрес своего домена в поле URL, чтобы узнать, работает ли перенаправление.
Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.