Developer Tools

htaccess Redirect Generator

Live

Calculate apache redirect rule from source path, target url, redirect status, preserve query string.

About htaccess Redirect Generator

Calculate apache redirect rule from source path, target url, redirect status, preserve query string. Enter source path, target url, redirect status, preserve query string in a purpose-built htaccess redirect generator interface designed for this subject. Paths are regex-escaped and serialized into an Apache mod_rewrite redirect with explicit status and query behavior. The result includes apache redirect rule, matched pattern, flags, supporting detail, and clear units or diagnostics. Results depend on the entered assumptions, units, supported input range, and rounding. Review important decisions against authoritative requirements. Processing stays in your browser, and UtilityPages does not store the values you enter.

Set up htaccess Redirect Generator

Workspace

Source workbench

Edit the source fields below and inspect the rendered output alongside your work.

This workspace updates as you edit.

Enter source path.

Enter target url.

Enter redirect status.

Enter preserve query string.

htaccess Redirect Generator result

Enter the values above, then process to see a detailed result.

How htaccess Redirect Generator works

Paths are regex-escaped and serialized into an Apache mod_rewrite redirect with explicit status and query behavior.

How it works

Paths are regex-escaped and serialized into an Apache mod_rewrite redirect with explicit status and query behavior. Results depend on the entered assumptions, units, supported input range, and rounding. Review important decisions against authoritative requirements.

Examples

htaccess Redirect Generator worked example

Example input
{
    "source_path": "/old-page",
    "target_url": "https://example.com/new-page",
    "status": "301",
    "preserve_query": "yes"
}
Expected result
{
    "rule": "RewriteRule ^old-page/?$ https://example.com/new-page [R=301,L]",
    "pattern": "^old-page/?$",
    "flags": "R=301,L"
}

Privacy

This tool does not store your inputs or results on UtilityPages.org.

Citations & sources

  1. Web APIs

Frequently asked questions

How does the htaccess Redirect Generator work?

Paths are regex-escaped and serialized into an Apache mod_rewrite redirect with explicit status and query behavior.

What information should I enter?

Enter source path, target url, redirect status, preserve query string. Use values and units from the same scenario so the result is internally consistent.

What results does this tool provide?

It reports apache redirect rule, matched pattern, flags, including intermediate context where it helps you review the answer.

What limitations should I know about?

Results depend on the entered assumptions, units, supported input range, and rounding. Review important decisions against authoritative requirements.