Htaccess Redirect Generator
Every time you migrate a blog, change your URL scheme or consolidate old pages, Apache’s .htaccess takes the brunt of the cleanup. This generator turns a simple source → target mapping into the correct RewriteRule directives with the right flags, ready to drop into the site’s .htaccess file.
How to generate redirect rules
-
1
Pick the redirect type
301 permanent for SEO-safe moves, 302 temporary for A/B tests and seasonal redirects.
-
2
Enter source and target
Exact paths or regex patterns: the old path becomes the RewriteRule pattern, the new URL becomes the redirect target.
-
3
Check the flags
Every rule gets the right flag, `[R=301,L]` or `[R=302,L]`, so the block works with mod_rewrite out of the box.
-
4
Copy the directives
The generated block goes inside the `<IfModule mod_rewrite.c>` section of .htaccess.
mod_rewrite vs mod_alias directives
Apache offers two modules for redirects. Pick based on the complexity of the rule.
Decision guide
| Requirement | Use | Example |
|---|---|---|
| Exact old URL → exact new URL | Redirect |
Redirect 301 /old /new |
| Wildcard prefix | RedirectMatch |
RedirectMatch 301 ^/blog/(.*)$ /articles/$1 |
| Query-string match | RewriteRule |
See below |
| Force HTTPS | RewriteRule |
RewriteCond %{HTTPS} off + rule |
| Conditional (browser, cookie) | RewriteRule |
With RewriteCond |
Example: force HTTPS with www
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Example: move /blog/post-123 to /articles/post-123
RewriteEngine On
RewriteRule ^blog/(.*)$ /articles/$1 [L,R=301]
Flags you will see
L, last, do not continue processing further rules.R=301orR=302, redirect with that status code.NC, case-insensitive.QSA, append original query string to the new URL.NE, do not re-encode special characters in the target.
Common mistakes
- Forgetting
RewriteEngine On, without it no RewriteRule has any effect. - Using 302 by default, Google treats it as temporary, so the old URL keeps ranking.
- Chained redirects (old → intermediate → final), always aim for a single hop; each extra hop loses link equity and adds latency.
Frequently Asked Questions
Use 301 for permanent moves: site migration, URL slug change, HTTPS upgrade. Use 302 only for temporary situations, like routing to a maintenance page or an A/B split. Search engines transfer ranking signals on 301, not reliably on 302.
The most common cause is forgetting the leading slash in the pattern. In RewriteRule, the pattern matches the path without the leading slash (e.g. ^blog/). In Redirect (mod_alias), the pattern does start with a slash (/blog). Do not mix the two conventions.
Yes, use RewriteCond %{QUERY_STRING} ^id=123$ before a RewriteRule. Plain Redirect does not read the query string; only RewriteRule can match on it.
Yes, on the next request, Apache re-reads .htaccess per request. No server restart needed. If nothing happens, check that AllowOverride All is set in the vhost for the directory.
Related Tools
ASCII Table Reference
Full ASCII table from 0 to 127 with decimal, hex, octal, binary, standard names and HTML numeric-reference notation, including NUL, LF and DEL.
Color Palette Generator
Generate monochromatic, analogous, complementary, triadic or tetradic color palettes from a base HEX color and export copy-ready CSS variables.
HTML Character Reference
Searchable list of HTML entities, their named and numeric codes, and a one-click copy for special characters and symbols.
HEX Color Picker
Pick or enter a HEX colour and get RGB, HSL, approximate CMYK, relative luminance and contrast ratios against white and black.
FPS Counter
Measure browser FPS with requestAnimationFrame, smoothing, min/max frame rate, warnings and an optional graph. Runs locally with no upload or API.
JSON Formatter
Paste JSON to pretty-print with 2 or 4 spaces, minify it to compact output, or run a quick syntax check before copying the result.
Tool available in other languages
- Htaccess Weiterleitungs-Generator [DE]
- ตัวสร้าง Redirect สำหรับ Htaccess [TH]
- Generator przekierowań .htaccess [PL]
- Gerador de Redirecionamento Htaccess [PT]
- Htaccess-omdirigeringsgenerator [SV]
- Bộ tạo đường dẫn chuyển hướng Htaccess [VI]
- Generator Redireksi Htaccess [ID]
- Generador de redirección Htaccess [ES]
- Htaccessリダイレクトジェネレータ [JA]
- Htaccess 리다이렉트 생성기 [KO]
- Générateur de redirection Htaccess [FR]
- مولد إعادة توجيه Htaccess [AR]
- Htaccess-redirectgenerator [NL]
- Generatore di Redirect Htaccess [IT]
- Генератор перенаправлений для Htaccess [RU]
- Htaccess Yönlendirme Oluşturucu [TR]
- Htaccess重定向生成器 [ZH]