On this page
A redirect can look correct at the starting URL but finish on a host that the release team did not approve. To check a redirect’s final destination host before launch, capture the entire chain, compare each hostname against an explicit list, and investigate unexpected results before signing off.
Key Takeaways
- Record the starting URL, every redirect response and destination, and the final response—not just the first and last URLs.
- Compare parsed, normalized hostnames exactly. Treat subdomains, ports, schemes, and visually similar names as separate policy decisions.
- Repeat checks for relevant authentication, region, browser, and session conditions.
- An approved-host list is a release QA control, not proof that a destination or redirect is secure.
- Keep live credentials, private preview URLs, personal query values, and session data out of shared evidence.
Prepare the staging check
- Build an inventory. Include URLs from the launch redirect map, important legacy URLs, campaign entry points, and representative URL variants. Assign an expected final destination or expected outcome to each entry.
- Agree on an approved host list. List exact hostnames and their owners. Decide separately whether staging hosts and identity-provider hosts are allowed as intermediate hops. Record which hosts may be final destinations.
- Define the test conditions. Identify the browsers, regions, authentication states, and session conditions that matter for release. Use approved test accounts and synthetic data.
- Set a hop limit. For example, stop after 10 redirects and flag the chain for review. Also flag a repeated URL as a possible loop.
An exact entry for example.com does not approve www.example.com, login.example.com, or example.com.other.example. Add each permitted hostname explicitly, or document and review a separate subdomain policy.
Advertisement
Capture the starting URL, hops, and final response
The following manual workflow uses a terminal for a basic HTTP check. It requires curl and network access to the staging site. The example URL is fictional; replace it with an authorized staging URL that contains no live credentials or personal data.
curl --silent --show-error --max-time 15 \
--dump-header - --output /dev/null \
'https://staging.example.com/old-page'
This sends a GET request, displays response headers, and discards the response body. It does not ask curl to follow redirects. Headers can contain cookies, tokens, or private locations, so inspect them locally and redact them before sharing.
- Record the starting URL in your local test notes. In shared evidence, use a sanitized identifier or synthetic URL instead.
- Inspect the response status and any
Locationheader. For a redirect the client would follow, resolveLocationagainst the current URL: a value such as/new-pageis relative to the current origin, while an absolute URL may specify another host. - Request the resolved destination using the same command. Record the status, destination hostname, and any next
Locationfor each hop. - Stop at a terminal response, a repeated URL, or the hop limit. A missing or invalid
Locationon an expected redirect is a failure to investigate. A terminal error response is not a successful launch check merely because its host is approved. - Compare the starting host, all intermediate hosts, and final host with the appropriate approved lists. Check the final path and outcome against the redirect map too.
Not every 3xx response is an ordinary navigation redirect; examine its status and context rather than assuming that any 3xx proves a usable chain. Network failures and timeouts should be recorded as inconclusive or failed checks, not as approved destinations.
Check browser behavior separately
The terminal workflow does not reproduce all browser behavior. In a browser’s developer tools, enable preservation of network logs, navigate from the starting URL, and inspect the document requests and their redirect responses. Also note any navigation initiated by page content, such as JavaScript or an HTML refresh; a simple HTTP header check can miss those.
Repeat the browser check using the relevant test matrix:
- Authentication: Check signed-out and signed-in states where applicable. A login or identity-provider redirect may be legitimate, but it should be an explicitly approved intermediate destination. Verify the post-login destination with a test account.
- Region: Check the supported regions using the team’s approved test environment. Record the region or routing condition; one region’s result does not establish another’s.
- Browser and session: Check the browsers in the release plan and compare a fresh session with a returning session where cookies or prior state could affect routing.
A chain may differ between these conditions. Treat each expected variation as its own result rather than overwriting earlier evidence. Do not export raw browser network logs for general sharing without reviewing them for cookies, authorization headers, private URLs, and personal data.
Advertisement
Compare hostnames accurately
Parse URLs before comparing them. Do not search the raw URL for an approved domain: a domain-like string can appear in a path, query, user-information field, or a longer hostname without being the actual host.
Use these rules when reviewing each parsed URL:
- Hostname: Compare the normalized hostname against an exact, lower-case allowlist. A hostname comparison should not silently approve subdomains.
- Lookalikes: Inspect the parser’s normalized hostname, not only its visual appearance. Internationalized names and similar-looking characters can make different hosts appear alike. Investigate unexpected spelling or encoding instead of adding it automatically.
- Ports: A hostname alone does not include the port. Decide which scheme and effective port combinations are acceptable. For example, an approved hostname on an unexpected non-default port may need review.
- Trailing dots: Decide whether to reject or explicitly normalize a final dot in a hostname. Apply the same policy to both test data and the approved list; the example below rejects it.
- User information: Reject unexpected username or password components in URLs. Text before
@is not the destination hostname.
Example: check an observed chain
This illustrative browser-console snippet checks a fictional chain against exact hostnames and an HTTPS port policy. Replace the entries with sanitized test URLs before using it. It does not fetch URLs or discover redirects; capture the full chain first. Do not paste live credentials, private preview URLs, or personal query values into the console.
const approvedHosts = new Set([
'staging.example.com',
'www.example.com',
]);
// Replace with every captured URL, in order, including the starting
// and terminal URLs. These entries are illustrative only.
const chain = [
'https://staging.example.com/old-page',
'https://www.example.com/new-page',
];
for (const [index, value] of chain.entries()) {
try {
const url = new URL(value);
const hostname = url.hostname;
const effectivePort = url.port || (url.protocol === 'https:' ? '443' : '');
const approved =
url.protocol === 'https:' &&
effectivePort === '443' &&
!url.username &&
!url.password &&
!hostname.endsWith('.') &&
approvedHosts.has(hostname);
// Avoid printing the full URL, which might contain sensitive data.
console.log({ hop: index, hostname, effectivePort, approved });
} catch {
console.log({ hop: index, approved: false, reason: 'Invalid URL' });
}
}
The URL parser normalizes the hostname for comparison, and the example treats the default HTTPS port and an explicitly specified HTTPS port of 443 alike. Adapt the policy if your staging environment intentionally uses another scheme or port. In a real review, distinguish approved intermediate hosts from approved final hosts; the single set above demonstrates hostname matching only. An empty or incomplete chain cannot establish a passing result.
This article’s commands and snippet were not executed here, and the relevant documentation was not available to consult in this run. Verify behavior in your own staging environment and supported browsers before using the workflow for sign-off.
Common Mistakes
- Checking only the final URL. An unexpected intermediate host can still matter, even if the chain eventually returns to an approved destination.
- Using substring matching. A URL containing
example.comis not necessarily hosted onexample.com. - Treating an approved hostname as a blanket approval. The scheme, port, final path, application behavior, and purpose of the hop may still be wrong.
- Assuming one session represents everyone. Authentication, location, cookies, and browser behavior can change the result.
- Sharing raw evidence. Redirect headers and network logs may expose session data or private links. Redact them before placing evidence in tickets or reports.
Best Practices
For each test, keep a sanitized record containing a test-case ID, test conditions, hop count, each reviewed hostname and status, the final hostname, the expected outcome, and a pass or investigation decision. Restrict access to any necessary raw evidence and follow your organization’s retention rules.
Have an owner review exceptions, including intentional identity-provider hops, changed ports, and newly introduced hosts. Re-run affected cases after redirect rules or deployment configuration change.
The allowlist helps identify unexpected destinations; it is not a security guarantee. An approved host can still be misconfigured or contain an unsafe redirect, and this QA workflow does not replace application security review or server-side controls.
Conclusion
A useful pre-launch redirect check follows each chain under realistic test conditions and compares parsed hosts with explicit expectations. Preserve sanitized evidence, investigate differences, and sign off only when both the destination and the route to it are understood.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.