Redirecting a Domain to a URL with a Path Using CNAME

📢 This article was translated by gemini-3-flash-preview

I thought about doing this back when I had my own server, but since I could just set up another site on the server to solve it, I never looked into it deeply. Now that my server has expired and I’ve moved my blog to GitHub, that’s no longer an option. So, I went looking for a solution.

The Failed Attempt

Even though it failed, I’m documenting it anyway. I probably just didn’t know how to use it.

I previously tried playing around with just DNS CNAME records, but gave up when it didn’t work. This time, I searched for “redirect domain to path URL” and found a tool via the first search result ( https://cloud.tencent.com/developer/ask/sof/89340 ): http://redirect.center/ .

Example

Redirecting from https://acg.yexca.net to https://blog.yexca.net/acg .

Result: Inaccessible.

According to the site’s description, the CNAME content should be blog.yexca.net.opts-slash.acg.opts-https.redirect.center.. However, it didn’t work as expected and threw an error.

I tried a few variations, but they all errored out. I gave up and looked for another way.

Note: The last part of the website’s introduction has an auto-generator.

A New Tool

I searched for “redirect center” and found https://redirect.name/ as the third result.

This tool is much easier to use and, more importantly, it actually works.

New Example

Redirecting from https://twinkle.yexca.net to https://yexca.github.io/MusicPlayer-Twinkle/ .

Result: Accessible.

Two records are required:

TypeNameContent
CNAMEtwinklealias.redirect.name
TXT_redirect.acgRedirects to https://yexca.github.io/MusicPlayer-Twinkle/

Code format:

1
2
acg            IN  CNAME  alias.redirect.name
_redirect.acg  IN  TXT    "https://blog.yexca.net/acg"
This post is licensed under CC BY-NC-SA 4.0 by the author.
Last updated on 2025-01-05 15:40 +0900