.htaccess Redirect Generator
Describe the redirect you want and copy Apache 2.4 rules for a .htaccess file. Choose a status code and whether to use Redirect or RewriteRule. This page does not talk to your server and cannot prove that a rule will work.
Redirect options
These rules are not tested against a live server. Use a temporary 302/307 while you experiment — browsers cache 301 and 308.
Limits
- Apache 2.4 .htaccess / mod_alias / mod_rewrite syntax only. Not Nginx, IIS or Cloudflare Rules.
- Rules are not tested against a live server, and this page cannot read your current configuration.
- mod_rewrite flags are a conservative set (L, QSA or QSD when asked, R=code). Advanced maps, conditions on headers, or alias vs rewrite precedence are not modelled.
- Internationalized domain names and unusual percent-encoding may need manual adjustment.
- A wrong 301 can be cached by browsers and CDNs. Test with a temporary code first.
Generated rules
How to use .htaccess Redirect
- Choose a typeA single path to path, force HTTPS, force www or non-www, or a trailing-slash rule.
- Set the status and paths301, 302, 307 or 308, plus the from/to paths or host names.
- Copy the rulesPaste them into a .htaccess file (or a VirtualHost). You still need AllowOverride and, for RewriteRule, mod_rewrite.
What you still have to do on the server
The generator prints Apache 2.4 directives. Redirect lives in mod_alias. RewriteRule and RewriteCond need mod_rewrite and usually RewriteEngine On. A .htaccess file only works if the vhost allows overrides. This page cannot enable those modules or test the result.
Nginx, IIS, Cloudflare and Caddy use different syntax — do not paste these rules there. Query strings, encoded characters and trailing slashes are easy to get wrong; review the rule and test it on a staging host. A 301 is cached aggressively by browsers, so prefer 302 while you are experimenting.
Frequently asked questions
Is my text or file uploaded?
No. Everything runs in your browser tab with JavaScript. Nothing you type, paste or drop is sent to a server, logged or stored by ALink Tools.
Why is nothing happening on my site?
mod_rewrite or AllowOverride may be off, the file may be in the wrong directory, or a parent config may take precedence. This page cannot inspect your server. Check the Apache error log.
Should I use 301 or 302?
301 (and 308) means a permanent move and is cached. Use 302 or 307 while testing. 307/308 keep the original request method; 301/302 may turn a POST into a GET in older clients.
Can you generate Nginx rules?
Not in this version. The output is Apache only.
Related tools
All toolsrobots.txt Generator
Create robots.txt rules, AI crawler blocks and sitemap lines.
XML Sitemap Generator
Turn a list of URLs into a valid sitemap.xml file.
URL Encoder / Decoder
Percent-encode or decode URLs, query strings and form values.
Redirect Checker
Trace every 301, 302, 307 and 308 hop from a URL to the final page.