Remapping One URL to Another
Say you move your website from one domain to another. How do you know if you missed to migrate any old links? 🤔
You can check that using lychee’s --remap
option!
Here’s how to check all the links in your sitemap after
migrating your website from example.com
to example.org
:
The --remap
option takes a list of space-separated pairs of strings.
The first string is the old URL pattern and the second string is the new URL pattern.
In this example, the old domain is replaced with the new domain in all links.
You can use this option multiple times to remap multiple domains and you can use regular expressions.
You can also check the migration on a local dev
version of your website:
Of course you can also combine this with other lychee features. In the below example we limit the number of concurrent requests to 4 to not overload the server.
Remap is a powerful feature. Instead of just replacing domains, you can also use regular expressions to replace parts of the URL.
For example, if you want to migrate from GitHub to GitLab, you can use this command:
This will replace all links from github.com
to gitlab.com
while keeping the
rest of the URL intact.
You can also use named capture groups to replace parts of the URL with a different name:
For more information about the --remap
option, see #620, #1129, and the example config file.