How to redirect old domain names

Sometimes we need to redirect access to another domain name,For example, when the old domain name is walled。

Some domain name providers provide this service,But the functions are very basic,Only simply match the domain name and then jump,And this jump will lose parameters and other information,Or simply fail to match,Basically unusable。

To redirect the domain name and retain the request parameters,You need to have a dedicated server to accept the request and return the redirect information。This requirement cannot be achieved simply by DNS。

Using a server

Since I have a blog server,And I used it hestia panelManage server,So it's easy to create an empty website,Then use apache .htaccess To achieve matching jump。

You just need to create this file in the website root directory,Then write in it:

In the above example, old-domain and new-domain It's your old domain name and new domain name,Just modify it accordingly (note that the domain name suffix must also correspond to it,Don't keep com)。Such,You just need to resolve your domain name to this server,You can jump。equally,You can also add multiple alias to the website,This allows you to parse multiple subdomains here,Forward。

Using Cloudflare

If you don't have a convenient server for domain name parking,You can also consider using cf's free service。This is Gemini 2.5 The result generated by pro,I didn't try,But it is also feasible in theory。There are two potential drawbacks:

  1. Unstable parsing,cf Many nodes in the country are interfered and blocked
  2. Long migration time,Need to modify the ns proxy,The effective time can be reached 24 hour,During this period, the domain name may not be resolved.,It's hard to do。Because you have to put the domain name into cf to operate

Operation steps:

  1. Register a Cloudflare account:If you haven't,You can register for one for free。
  2. Add old domain name:Add your old domain name that is about to expire in Cloudflare。
  3. Change NS records:Cloudflare will provide you with two new Nameserver (NS) addresses。You need to log in to youOld domain nameregistrars (such as GoDaddy, Namecheap, etc.),Modify the NS record of this domain name to the two provided by Cloudflare。This process usually takes several hours to 48 hours to take effect。
  4. Set jump rules
    • In Cloudflare Control Panel,Find your old domain name,Then enter "Rules” > “Redirect Rules” (This is a newer feature) or "Page Rules” (Old features,Still available)。
    • Create a rule:
      • If incoming requests match… (When the URL to be accessed is): old-domain.with/*
      • Then… (Then execute):
        • Type: Dynamic (If it is Redirect Rules)
        • URL redirect: https://new-domain.com{http.request.uri.path} (This is the syntax of Redirect Rules)
        • or Forwarding URL (If it is Page Rules): https://new-domain.com/$1
        • Status code: 301 Permanent Redirect

    here * and {http.request.uri.path} or $1 Is the key。They are wildcards and variables,Represents all paths and parameters behind the domain name,Ensure that the request can be passed intact。

 

Original article written by LogStudio:R0uter's Blog » How to redirect old domain names

Reproduced Please keep the source and description link:https://www.logcg.com/archives/3896.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Leave a Reply

Your email address will not be published. Required fields are marked *