HTACCESS Redirect Generator
Generate .htaccess redirect rules.
Runs in your browser Your input never leaves your device.
About this tool
Generate Apache .htaccess lines that redirect one path to another URL. Enter the old path, the full destination URL and choose 301 (permanent) or 302 (temporary). The output gives a simple Redirect directive, plus an equivalent mod_rewrite block that is commented out, so you can paste everything without applying two rules: remove the Redirect line and the leading # characters if you prefer mod_rewrite. Regex characters in the path are escaped for you in the rewrite pattern. The text is generated in your browser; copy it into your .htaccess file. It only works on Apache servers (or compatible ones) with .htaccess enabled.
How to use it
- Enter the old path, starting with a slash.
- Enter the full destination URL.
- Choose 301 for a permanent move or 302 for a temporary one.
- Copy one of the two options into your .htaccess file.
Example
From /old-page, To https://example.com/new-page, Type 301
# Apache .htaccess Redirect 301 /old-page https://example.com/new-page # Alternative with mod_rewrite (use this OR the Redirect line above, not both): # RewriteEngine On # RewriteRule ^old-page$ https://example.com/new-page [R=301,L]
Common problems
- Redirect does nothing
- The .htaccess file may be disabled (AllowOverride) or your server may not be Apache. Nginx and others need their own configuration.
- I want the RewriteRule instead
- Delete the Redirect line and remove the # at the start of the three mod_rewrite lines.
- Special characters in the path
- In the mod_rewrite lines regex characters are escaped. Spaces and query strings are not handled, so quote or adjust those by hand.