Skip to content

URL Rewrites

A rewrite changes the address nsin sends to your server, while the visitor keeps seeing the address they typed. Nothing appears in the browser’s address bar — no redirect, no extra round trip.

This is the difference from a redirect:

Visitor’s address barExtra round trip
RedirectChangesYes
RewriteStays the sameNo
  • Your site moved to a new folder on the server, but you want the old public addresses to keep working exactly as they were.
  • You want a clean public address (/blog/hello) served by a messier internal one (/index.php?p=hello).
  • You’re serving one section of the site from a different application and want the paths to line up.
  1. Go to RulesAdd RuleURL Rewrite.
  2. Set which addresses it applies to (the path match).
  3. Set the path sent to your server.
  4. Choose what happens to the query string (see below).
  5. Save.

The query string is the ?a=1&b=2 part. You choose one of:

  • Keep — pass it through unchanged. This is the usual choice.
  • Replace — send a fixed query string of your own instead.
  • Remove — drop it entirely before your server sees it.

Paths can be matched two ways:

  • Wildcard/old/* matches everything under /old/. Easy and safe.
  • Regular expression — for when you need to capture part of the address and reuse it in the target. Capture groups from the match can be referenced in the path you send to your server.

You can also exclude paths that would otherwise match, which is handy for carving one folder back out of a broad rule.

Serve the old address from the new folder

  • Applies to: /downloads/*
  • Send to your server as: /files/*
  • Query string: keep

A visitor asking for /downloads/report.pdf gets the file your server has at /files/report.pdf, and their address bar still says /downloads/report.pdf.

Should I use a rewrite or a redirect? If you want old links to keep working invisibly, rewrite. If you want people and search engines to learn the new address, redirect.

My rewrite doesn’t seem to do anything. Rewrites only run for traffic that goes through nsin. Check that the record for that hostname is proxied — see Managing DNS Records.

Two rules both match the same address. The one higher in the list wins. See Rules Overview.