iGdu

耕读

Learner and Observer, be happy to share useful things.

About Xlog Custom Domain and Redirect Settings

Xlog's bloggers gather various experts, including technical gurus familiar with Web3, blockchain technology, encrypted wallets, and network technology novices who simply want to share content.

As a network technology novice, when customizing the domain name for the Xlog blog, I discovered some issues with URL redirection. It seems that Xlog doesn't have a tutorial for naked domain redirection. (After finishing this blog post, I came across this tutorial, but it also doesn't cover naked domain redirection settings.) I followed the tutorial from ChatGPT and consulted Diygod, and finally managed to resolve 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. Configuring and improving Xlog subdomain#

Perhaps when you first registered with Xlog, you randomly chose an Xlog subdomain. However, subdomains can be modified, so it is recommended to change it to a short, memorable, or impressive subdomain. For example, I modified 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 a 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 name ownership.

As shown in the image:

xlogdomain (1)

Since my domain is hosted by Cloudflare, when verifying domain name ownership, you need to go to the Cloudflare account service that hosts the igdux.com domain and set the domain name 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, blog platforms have domain name redirection options in the backend, such as Google Blogger (note: Blogger defaults to redirecting from a domain name without www to a domain name with www). However, Xlog does not have a domain name redirection option in the backend. 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 the image below:

xlogdomain4

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

xlogdomain (2)

3.2 Setting up 301 redirection rules#

In your Cloudflare account, select the custom domain name that is bound to your 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. Set them up as shown in the image.

After completing steps 3.1 and 3.2, you can access your blog through your domain name and achieve naked domain redirection. For example, with my domain name, 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.

Note:#

Although Google Blogger has domain name redirection in the backend, by default, Blogger redirects 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.