How to Find URLs Pointing to an Old Domain

Find URLs pointing to an old domain with a text-only CSV audit. Match subdomains accurately, protect private URLs, and plan remediation.

Published
Reading time
8 min read
How to Find URLs Pointing to an Old Domain
On this page

A retired domain can remain in a URL inventory long after a migration. To find URLs pointing to an old domain, compare each URL’s hostname with the retired domain—not the entire URL as a string. That distinction catches its subdomains without confusing them with similar-looking names or mentions in paths and query strings.

This guide shows a text-only review process and a CSV script. Neither requires opening a destination. The script has not been executed in this environment, so review and test it against a copy of your inventory before relying on its results.

Key Takeaways

  • Match the retired hostname exactly, or match a hostname ending in a dot followed by that hostname. For retired.example, this includes docs.retired.example but not notretired.example or retired.example.other.example.
  • Send malformed, relative, non-HTTP, or otherwise ambiguous URLs for manual review rather than treating them as clean matches or non-matches.
  • Record where each link appears, its destination host, a business owner, a proposed action, and its review status.
  • Verify who controls the old domain before recommending a redirect. Updating the link at its source may be necessary even when a redirect exists.
  • Keep private inventories in an authorized environment. A text-only review does not need to visit the URLs.

Define the hostname boundary

Suppose the retired domain is retired.example. Compare the hostname, ignoring case and a single final DNS dot:

URLClassificationReason
https://retired.example/pageMatchExact hostname
https://docs.retired.example/pageMatchSubdomain with a dot boundary
https://notretired.example/pageNo matchSimilar spelling, but a different hostname
https://retired.example.other.example/pageNo matchThe retired name is not the hostname’s ending domain
https://current.example/path/retired.exampleNo matchThe old name is in the path, not the host

This process identifies direct destination hosts. It does not identify a redirect from another host to the retired domain, or a retired URL embedded inside a query parameter. If those matter, make them separate audit tasks; do not assume a hostname match covers them.

Advertisement

Prepare an inventory

Export a CSV with these columns:

source_location,url,business_owner
"Help center: migration guide","https://docs.retired.example/start","Documentation"
"Campaign email template","https://current.example/retired.example","Marketing"
"Partner integration record","https://retired.example/callback","Integrations"

source_location should identify where someone can find and edit the link, such as a page, template, repository file, or system record. Use internal identifiers instead of sensitive details where practical. If ownership is unknown, leave business_owner blank and assign it during triage.

The review output should retain those fields and add:

  • destination_host: The parsed host, when it can be assessed safely.
  • classification: match, no_match, or manual_review.
  • proposed_action: An initial routing instruction, not an approved change.
  • review_status: A workflow state, initially pending in the example below.

A review status is separate from the classification: even a no_match row may need review if your export is incomplete or your scope includes embedded URLs.

Classify a CSV without visiting URLs

The following example uses Python’s standard library. Save it as audit_urls.py; provide a local CSV with the three headers shown above. The target must be an ASCII DNS hostname, not a URL. The script reads the file and writes a new CSV; it does not make network requests.

import argparse
import csv
import re
from urllib.parse import urlsplit

LABEL = re.compile(r"^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$")


def normalize_host(host):
    # This conservative check accepts ASCII DNS-style names only.
    if not host or not host.isascii():
        return None
    host = host.lower()
    if host.endswith("."):
        host = host[:-1]
    if not host or len(host) > 253:
        return None
    if not all(LABEL.fullmatch(label) for label in host.split(".")):
        return None
    return host


def classify(raw_url, target):
    # Avoid silently accepting controls stripped by a URL parser, or
    # browser-specific interpretations of backslashes and whitespace.
    if not raw_url or any(ord(c) <= 32 or ord(c) == 127 or c == "\\" for c in raw_url):
        return "", "manual_review"

    try:
        parts = urlsplit(raw_url)
        if parts.scheme.lower() not in ("http", "https") or not parts.netloc:
            return "", "manual_review"
        if parts.username is not None or parts.password is not None:
            return "", "manual_review"
        host = normalize_host(parts.hostname)
        # Accessing port also checks whether a supplied port is valid.
        _ = parts.port
    except ValueError:
        return "", "manual_review"

    if host is None:
        return "", "manual_review"
    if host == target or host.endswith("." + target):
        return host, "match"
    return host, "no_match"


def main():
    parser = argparse.ArgumentParser(description="Classify URL hosts in a CSV without fetching them.")
    parser.add_argument("domain", help="retired ASCII DNS hostname")
    parser.add_argument("input_csv")
    parser.add_argument("output_csv")
    args = parser.parse_args()

    target = normalize_host(args.domain)
    if target is None:
        parser.error("domain must be an ASCII DNS-style hostname")
    if args.input_csv == args.output_csv:
        parser.error("input and output must be different files")

    required = {"source_location", "url", "business_owner"}
    fields = ["source_location", "url", "destination_host", "business_owner",
              "classification", "proposed_action", "review_status"]
    actions = {
        "match": "Verify ownership and decide replacement or redirect",
        "no_match": "Confirm scope; no direct hostname match",
        "manual_review": "Inspect URL and source context manually",
    }

    with open(args.input_csv, newline="", encoding="utf-8-sig") as source:
        reader = csv.DictReader(source)
        if reader.fieldnames is None or not required.issubset(reader.fieldnames):
            parser.error("CSV must include source_location, url, and business_owner")
        with open(args.output_csv, "w", newline="", encoding="utf-8") as destination:
            writer = csv.DictWriter(destination, fieldnames=fields)
            writer.writeheader()
            for row in reader:
                raw_url = row.get("url") or ""
                host, result = classify(raw_url, target)
                writer.writerow({
                    "source_location": row.get("source_location") or "",
                    "url": raw_url,
                    "destination_host": host,
                    "business_owner": row.get("business_owner") or "",
                    "classification": result,
                    "proposed_action": actions[result],
                    "review_status": "pending",
                })


if __name__ == "__main__":
    main()

Run it with separate input and output files:

python audit_urls.py retired.example inventory.csv audit.csv

The expected classifications for the sample inventory are match, no_match, and match, respectively. Check those results yourself, then add cases from your own inventory. In particular, test a subdomain, a similar-looking hostname, a trailing dot, a relative URL, and a malformed port.

The script deliberately routes Unicode hostnames, IP literals, URLs with credentials, and other ambiguous inputs to manual review. For internationalized domains, establish a consistent hostname-normalization policy for your environment before extending the script. Relative URLs require the base URL from their source context; do not infer one from the text alone.

Use genuinely separate files: the script checks for identical path strings but does not detect different paths that refer to the same file. Keep a backup of the original export.

Advertisement

Decide what to do with each match

First assign a business owner and identify the intended replacement, if any. Then verify the old domain’s registration and control through your organization’s authorized domain-management records and administrators. Do not assume that a domain is yours merely because old links use your brand.

  • Still owned and controlled by your organization: The responsible team can assess whether a redirect is appropriate. Confirm the destination and path mapping, HTTPS availability, and operational ownership. Update important links at their source as well; a redirect does not correct the inventory itself.
  • Expired: Treat control as uncertain until verified. Ask the authorized domain team to investigate recovery or registration and any legal or operational implications. Do not promise that the domain can be recovered or that a redirect can be configured. Update source links to approved destinations where possible.
  • Controlled by another party: Do not recommend configuring a redirect on that domain. Update or remove the links at their source, and escalate sensitive or business-critical references to the appropriate owner. Avoid sending users to the old destination merely to test it.

For every decision, record the approved replacement or removal, the person responsible, and a status such as pending, approved, updated, or exception. If a link cannot be changed—for example, in a previously distributed document—record the limitation and owner rather than marking it fixed.

Common Mistakes

  • Searching for the domain anywhere in the URL. This flags paths and query strings and can miss the distinction between retired.example and a different hostname.
  • Using a suffix without the dot boundary. A check for any hostname ending in retired.example would also accept notretired.example.
  • Treating parsing as a safety verdict. A matched hostname tells you where a URL points syntactically; it does not establish who controls it or whether it is safe to visit.
  • Discarding ambiguous rows. Relative links, malformed URLs, and unsupported formats need source context or a separate normalization process.
  • Assuming a redirect fixes every reference. Redirects require control of the old domain and a maintained destination; source updates remain important.

Best Practices

Keep the inventory and results in approved storage with access limited to the people doing the review. URLs can contain private paths, identifiers, or tokens. Do not paste a private inventory into an online tool unless your organization has approved that disclosure.

Treat exported values as untrusted text. If opening the CSV in spreadsheet software, use an approved import process that prevents formula interpretation; ordinary CSV quoting alone is not a formula-injection safeguard. Work from a copy, preserve the source location, and reconcile the reviewed rows with the export so that missing or rejected records are visible.

Repeat the audit after source owners make changes, and review the remaining matches and manual-review rows. This is still a text-only check: verifying that a destination works is a separate, authorized task with its own safety considerations.

Conclusion

A reliable retired-domain audit starts with a boundary-aware hostname comparison, then turns each match into an owned decision. Verify domain control before proposing redirects, update source links where possible, and keep ambiguous and private URLs in a controlled review workflow.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.