On this page
A redirect can move a request to the right page while silently dropping information from its path. For applications that use semicolon-delimited path parameters, such as /item;color=blue, that can change how the destination handles the request.
This workflow helps you preserve semicolon parameters in URL redirects when that is the intended contract. It records every redirect hop, checks the request target received at a controlled final endpoint, and distinguishes accidental loss from intentional cleanup.
Key Takeaways
- Define the expected final path for each route before testing; not every semicolon parameter should necessarily survive.
- Record each response status and
Location, then check what the final server actually receives. A redirect checker can show behavior but cannot by itself explain which component caused a rewrite. - Test literal semicolons, encoded semicolons, parameters on multiple segments, and explicitly obsolete parameters separately.
- Repeat the same cases against the proposed configuration in staging before release.
Define the path contract
A semicolon can appear within a URL path segment. An application or framework may interpret the text following it as a parameter associated with that segment. For example, an application might treat /catalog;lang=en/item;color=blue as two segments with separate parameters. That interpretation is application-specific: another component may simply treat the semicolons as path characters.
These are distinct test inputs:
/item;color=blue: a literal semicolon in the path./item%3Bcolor=blue: a percent-encoded semicolon./catalog;lang=en/item;color=blue: parameters on more than one segment./item;legacy=1: a parameter the application may deliberately retire.
Do not assume the encoded and literal forms are interchangeable. A proxy, redirect rule, or framework can operate on a raw, decoded, normalized, or reconstructed path. Decoding before a rule runs can also change which characters that rule sees. Query strings are separate from the path, and URL fragments are not sent in HTTP requests.
Before testing your own route, specify whether the contract requires exact encoded bytes or only equivalent application behavior. The example below uses an exact request-target comparison, so a change from %3B to ; is a failure even if your application treats them equivalently.
Advertisement
Run a controlled before-and-after test
The following local fixture simulates two redirect hops. Its baseline mode intentionally loses two parameters; its candidate mode preserves them. Both modes intentionally remove legacy=1. This is a demonstration of a test method, not a model of any particular proxy or framework.
The examples require Python 3 and use only its standard library. They have not been executed in this article.
1. Start the fixture
Save this as redirect_fixture.py:
import json
import sys
from http.server import BaseHTTPRequestHandler, HTTPServer
if len(sys.argv) != 2 or sys.argv[1] not in ("baseline", "candidate"):
raise SystemExit("Usage: python3 redirect_fixture.py baseline|candidate")
mode = sys.argv[1]
# Values are the path suffixes used by the first redirect.
routes = {
"/old/item;color=blue": "item;color=blue",
"/old/item%3Bcolor=blue": "item%3Bcolor=blue",
"/old/catalog;lang=en/item;color=blue": "catalog;lang=en/item;color=blue",
"/old/item;legacy=1": "item",
}
if mode == "baseline":
routes["/old/item;color=blue"] = "item"
routes["/old/catalog;lang=en/item;color=blue"] = "catalog/item"
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path in routes:
self.redirect("/via/" + routes[self.path])
elif self.path.startswith("/via/"):
self.redirect("/new/" + self.path[len("/via/"):])
elif self.path.startswith("/new/"):
# This controlled endpoint reports the target received by the server.
body = json.dumps({"request_target": self.path}).encode("utf-8")
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
else:
self.send_error(404)
def redirect(self, location):
self.send_response(302)
self.send_header("Location", location)
self.send_header("Content-Length", "0")
self.end_headers()
server = HTTPServer(("127.0.0.1", 8080), Handler)
try:
server.serve_forever()
except KeyboardInterrupt:
pass
finally:
server.server_close()
Start the baseline in one terminal:
python3 redirect_fixture.py baseline
The fixture listens only on the local loopback address. Stop it with Ctrl+C when switching modes.
2. Record hops and assert the final target
Save this as check_redirect.py. It follows a limited number of redirects on the same origin, prints each hop, and compares the final endpoint's reported request target with the expected value. It is a test client, not a security control for a URL-fetching service.
import json
import sys
from urllib.error import HTTPError, URLError
from urllib.parse import urljoin, urlsplit
from urllib.request import HTTPRedirectHandler, Request, build_opener
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
def origin(url):
parts = urlsplit(url)
if (parts.scheme not in ("http", "https") or not parts.hostname
or parts.username is not None or parts.password is not None
or parts.fragment):
raise ValueError("URL must be HTTP(S), without credentials or a fragment")
port = parts.port or (443 if parts.scheme == "https" else 80)
return (parts.scheme, parts.hostname, port)
def check(start_url, expected):
allowed_origin = origin(start_url)
opener = build_opener(NoRedirect())
current = start_url
for hop in range(9):
if origin(current) != allowed_origin:
raise ValueError("Redirect leaves the starting origin")
request = Request(current, method="GET")
try:
response = opener.open(request, timeout=5)
except HTTPError as error:
# urllib represents unfollowed redirects and HTTP errors this way.
response = error
with response:
status = response.status
location = response.headers.get("Location")
print(f"hop={hop} url={current!r} status={status} location={location!r}")
if status in (301, 302, 303, 307, 308):
if not location:
raise ValueError("Redirect has no Location header")
current = urljoin(current, location)
continue
if status != 200:
raise ValueError(f"Unexpected final status: {status}")
body = response.read(65537)
if len(body) > 65536:
raise ValueError("Final response is too large")
data = json.loads(body.decode("utf-8"))
if not isinstance(data, dict):
raise ValueError("Final JSON response must be an object")
received = data.get("request_target")
print(f"received={received!r} expected={expected!r}")
if received != expected:
raise ValueError("Final request target does not match")
return
raise ValueError("Redirect limit exceeded")
if len(sys.argv) != 3:
raise SystemExit("Usage: python3 check_redirect.py START_URL EXPECTED_TARGET")
try:
check(sys.argv[1], sys.argv[2])
except (ValueError, URLError, OSError, UnicodeError) as error:
print(f"FAIL: {error}", file=sys.stderr)
raise SystemExit(1)
In another terminal, run the four cases. The quotes prevent the shell from treating semicolons as command separators.
python3 check_redirect.py 'http://127.0.0.1:8080/old/item;color=blue' '/new/item;color=blue'
python3 check_redirect.py 'http://127.0.0.1:8080/old/item%3Bcolor=blue' '/new/item%3Bcolor=blue'
python3 check_redirect.py 'http://127.0.0.1:8080/old/catalog;lang=en/item;color=blue' '/new/catalog;lang=en/item;color=blue'
python3 check_redirect.py 'http://127.0.0.1:8080/old/item;legacy=1' '/new/item'
The intended baseline result is failure for the literal and multi-segment preservation cases, and success for the encoded and deliberate-removal cases. Stop the fixture, restart it with python3 redirect_fixture.py candidate, and repeat the same four commands. In the candidate, all four are intended to pass. A successful command exits with status zero; a mismatch or request failure exits nonzero.
The fixture's final JSON value comes from the server's request target, rather than being inferred solely from the last Location. In a real stack, an equivalent endpoint or trusted backend instrumentation should report what the application actually receives. Be precise about where it measures: a framework's path property may already be decoded or normalized and may not represent the raw request target seen by an upstream proxy.
Advertisement
Apply the workflow in staging
- Write the expected mapping. List representative old targets and exact expected final targets. Include an explicit case for every parameter that should be removed. Add query-string cases if your redirects must preserve queries too.
- Capture the baseline. Run the checks against the existing staging configuration and retain the hop records and exit statuses. Use synthetic values; URLs and logs can expose sensitive information.
- Deploy the candidate configuration. Keep the test inputs and expected targets unchanged. Record the configuration or build identifier so the two runs are comparable.
- Repeat and compare. A difference in an intermediate
Locationidentifies the first visible hop where the URL changed. Check the final endpoint's observation as well: an intermediary can rewrite a request without issuing another redirect. - Investigate the responsible layer. Correlate the hop records with access logs and configuration at the edge, proxy, and application. Check route matching, path normalization, decoding, parameter stripping, and redirect construction at each relevant boundary. Restrict detailed logging and remove the diagnostic endpoint after testing.
- Gate the release. Require the agreed cases to pass, review intentional removals separately, and retain a rollback plan if the production route behaves differently.
The sample client expects a same-origin chain and a final JSON response containing request_target. Adapt it only after agreeing how your staging endpoint reports that value. Cross-origin redirects, authentication, and a destination that cannot expose a diagnostic response need a different authorized test arrangement; do not forward credentials blindly across origins. A production redirect chain may also have caching or edge behavior that a staging setup does not reproduce.
Check documentation for your actual stack
Frameworks, proxies, and redirect-rule engines can apply different path handling, and their behavior can depend on configuration and version. Consult the official documentation for the exact versions in your request path. Look for sections on raw versus decoded request paths, path or matrix parameters, normalization, rewrite variables, and redirect Location construction. Also check relevant release notes before relying on a previous environment's behavior.
No stack documentation was available to consult for this article, so it does not assert defaults for a named product. Verify those details against your deployed components rather than attributing a changed path to a specific layer based only on the redirect trace.
Common Mistakes
- Checking only the final status. A successful response does not establish that the destination received the intended path.
- Assuming
%3Band;follow the same route. Test both and define whether byte-level or semantic equivalence matters. - Testing only the last segment. A rewrite can preserve one segment's parameter while dropping another's.
- Treating intentional removal as a regression. Encode approved removals in the expected results and document why they are safe.
- Assuming a hop trace explains the cause. Use it to locate observable changes, then inspect the relevant component's configuration and logs.
Best Practices
Keep the test cases alongside redirect configuration or release checks. Use staging data that contains no credentials or personal information, and avoid logging sensitive query strings. When comparing paths, state whether percent-encoding normalization is allowed. If downstream behavior depends on parsed parameter values, add application-level assertions in addition to the exact-target check.
Conclusion
Treat semicolon parameters as part of the redirect contract, not incidental path text. Compare each hop and the final application's observed target before and after a change, while keeping intentional removals explicit.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.