Web Server Rule Generator

Generate supported redirect or cache rules with editable examples for the selected server.

On-device No sign-up Free to use

Generate server rules controls

?

A literal root-relative ASCII path. No query, percent escapes, dot segments, regex or directive characters.

?

Used for redirects. Absolute HTTP(S), without credentials; the destination query replaces the original query.

?

Used for cache snippets; only this exact public static asset is matched.

Processed in your browser. Your inputs stay on this device.

Showing an example. Change the fields, then use generate server rules to update it.

Result

Showing an example.

Generate an exact nginx redirect from /old-page to a fixed HTTPS destination.

Generated a snippet for the selected server context.
location = "/old-page" {
    return 301 "https://example.com/new-page";
}

Loading the tool. Your result will appear here.

https://usefreetools.net/web-server-rule-generator · 20 November 2026

Was this helpful?

How to use Web Server Rule Generator

  1. Choose nginx server block or Apache 2.4 domain-root .htaccess, then select Redirect or Cache.
  2. Enter one literal root-relative path. For Redirect, choose the destination and status; for Cache, use a supported public static-asset path and whole cache days.
  3. Select Generate server rules. Copy the snippet or download nginx-snippet.conf or apache-snippet.htaccess for the selected server.
  4. Review the surrounding configuration and run the server’s syntax check before activation. Test matching and nonmatching paths and the actual response; this generator changes no settings.

Example: Web Server Rule Generator

Generate an exact nginx redirect from /old-page to a fixed HTTPS destination.

You add
Server and snippet context: nginx; Rule type: redirect; Exact source or asset path: /old-page; Redirect destination: https://example.com/new-page; Redirect status: 301; Static asset cache days: 7
You get
Generated a snippet for the selected server context. location = "/old-page" { return 301 "https://example.com/new-page"; }

Options

Server context
nginx snippets belong inside the intended server block. Apache snippets target a domain-root .htaccess: redirects need mod_rewrite; cache rules need mod_headers and an allowed override context. Existing root/alias, rewrite and access rules still matter.
Redirect query and status
The entered destination replaces the original query string, retaining any query written in the destination. Choose 301, 302, 307 or 308 deliberately; 307 and 308 preserve the request method. Only one exact source path is generated.
Static caching
Choose one public CSS, JS, PNG, JPEG, WebP, SVG, ICO or WOFF2 asset and 0 to 365 whole cache days. This does not create a policy for dynamic or authenticated responses. The nginx form also checks that the requested file exists.

Supported inputs and limits

  • One literal ASCII root-relative path up to 1,024 UTF-8 bytes and, for redirects, an absolute HTTP(S) destination up to 2,048 bytes without credentials.
  • Queries in source paths, percent escapes, dot segments, duplicate slashes, regex input and directive/interpolation characters are refused.
  • Supported contexts are nginx server blocks and Apache 2.4 domain-root .htaccess.
  • Output is generated text: no server inspection, syntax check, activation, bulk rules, security policy or compression configuration is performed.

Where your input is processed

This tool does not upload your inputs. See the limits for anything saved on your device.

Test an exact rule before broadening it

The generated snippet does not change any server. Review syntax in the intended version and context, test the matching path and a nonmatching path, and inspect the actual redirect status and destination. Static caching applies to the exact named public asset; it is not a policy for authenticated or dynamic pages.

Questions about Web Server Rule Generator

Will generating a rule change my server?

No. The result is a text snippet for you to review.

Can I paste a regular expression or directive?

No. These fields accept the documented literal choices and reject configuration injection.

Can static-cache rules be used for account pages?

No. They are scoped to the named static-asset case; dynamic or private responses need their own policy.

Page updated · Project managed by Tony Hines · Report a problem with Web Server Rule Generator