iGdu

耕读

Learner and Observer, be happy to share useful things.

About Xlog custom domain and its redirection settings

Xlog's blogger, gathering various experts, including technical gurus familiar with Web3, blockchain technology, encrypted wallets, and also including network technology novices who just want to share content.

As a network technology novice, when customizing the domain name of the Xlog blog, I discovered some issues with URL redirection. It seems that Xlog blog does not have a tutorial for naked domain redirection. (After completing this blog post, I saw this tutorial, but it also does not have instructions for naked domain redirection). I followed the tutorial by ChatGPT and consulted Diygod, and finally resolved the issue. I am documenting it here and hope it can help other Xlog users. The steps for customizing the domain name are as follows:

1. Configuration and Improvement of Xlog Subdomain#

Perhaps when you first registered with Xlog, you randomly chose an Xlog subdomain. However, the subdomain can be modified, so it is recommended to change it to a short, memorable, or impressive subdomain. For example, I changed my Xlog subdomain to: https://igdu.xlog.app. The modification method is as follows: go to the Xlog console, click on Settings - Domain - set it to your desired domain name, and save it.

2. Setting Custom Domain#

Xlog provides a free custom domain solution. Here, I will use my Xlog blog https://igdux.com as an example. When I wanted to set the domain name of https://igdu.xlog.app to a custom domain name https://igdux.com, the setting method is as follows: go to the Xlog console, click on Settings - Domain - Custom Domain, enter your domain name, such as igdux.com (do not enter https:// or http://), at this point, Xlog will ask you to verify the domain ownership.

As shown in the image:

xlogdomain (1)

Since my domain is hosted by Cloudflare, when verifying domain ownership, you need to go to the Cloudflare account service that hosts the igdux.com domain to set the domain verification values: including a CNAME value and a TXT value. Fill them in as required.

As shown in the image:

xlogdomain (3)

If you have set it up, wait a moment, and you can access your blog through the custom domain (or the originally assigned xlog.app subdomain).

3. Setting up 301 Naked Domain Redirection#

Naked domain redirection refers to when you visit the domain name www.igdux.com, it will redirect to the domain name igdux.com without the www. And 301 means setting up a permanent redirect, not a temporary one, which is convenient for search engines to recognize and mark.

Usually, the blog platform's backend has an option for domain name redirection, such as Google Blogger (note: Blogger defaults to redirect from a domain name without www to a domain name with www). However, Xlog backend does not have an option to set domain name redirection. In this case, you need to go to your domain name registrar, such as Cloudflare, to set up domain name redirection.

3.1 Setting up www Domain Name Resolution#

There are two methods for setting up www domain name resolution, you can only choose one. Diygod chose method one, and I also successfully tested method two.

Method one: Add an IP resolution for a domain name with www. The A record value can be any standard IP value (not necessarily Cloudflare's IP), such as 192.0.2.1 or 108.162.192.233. After setting it up, it will look like this:

xlogdomain4

Method two: Add a CNAME resolution for a domain name with www, and the resolution value can be your Xlog.app subdomain. Using mine as an example:

xlogdomain (2)

3.2 Setting up 301 Redirection Rule#

Method one: Set up 301 redirection through Page Rule
Under your Cloudflare account, select your custom domain name that is bound to the xlog.app subdomain, for example, my custom domain name is igdux.com. Select the domain name - Rules - Page Rules, and set it up as shown in the image:

xlogdomain 4

URL: your domain name/* (such as google.com/*)

Pick a Setting: Forward URL; Select Status Code: 301

Enter Destination URL: https://yourdomainname/$1

Both /* and /$1 are commonly used in web development languages, so just follow the image to set it up.

After completing steps 3.1 and 3.2, you can access your blog through your domain name, and you can also achieve naked domain redirection: using my domain name as an example, when I visit https://www.igdux.com, it will automatically redirect to https://igdux.com. If you have set up the 3.2 domain 301 redirection rule but have not set up the 3.1 www domain name resolution, you may encounter an HTTP 502 error.
Method two: Set up 301 redirection through Redirect Rule
Since Cloudflare will soon stop supporting Page Rule rules, it is recommended to consider using Redirect Rule to set up 301 redirection in advance.
Under your Cloudflare account, select your custom domain name that is bound to the xlog.app subdomain. Select the domain name - Rules - Redirect Rules - Create Rule.
When creating a Redirect Rule, customize the rule name to something memorable, such as www2Rootdomain.

redirect

Fill in the redirection rule as shown in the image. Note that when setting your own "If" condition, modify the www.igdux.com in the image's Hostname equals www.igdux.com to your own domain name that needs to be redirected. In the "Then" condition, select Dynamic for Type, and select concat("https://igdux.com", http.request.uri.path) for Expression. You need to modify https://igdux.com to your target domain name for redirection. Select 301 for the redirection status code to achieve permanent redirection. After setting up the redirection rule, remember to add the domain name to Cloudflare CDN. This way, you can achieve permanent (301) redirection from the redirected domain name to the target domain name. (Method two, thanks to source 1 for the content)

Note:#

Although the Google Blogger backend has domain name redirection, Blogger defaults to redirecting from a domain name without www to a domain name with www. If a Blogger blogger wants to set up naked domain redirection, do not set the option to redirect from a domain name without www to a domain name with www in the Blogger backend. At the same time, refer to the settings in this article to achieve naked domain 301 redirection.

Acknowledgments:#

Thanks to Diygod and ChatGPT. With the help of ChatGPT and guidance from Diygod, I successfully resolved the domain name redirection issue.

————

Stay tuned:#

This article is also synchronized on iGengdu Blog and Linux.do Forum.

Regarding Xlog, please pay attention to the following articles I previously wrote:

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.