^old-page$
/from /to — separated by space or tab
Configure your redirect
Fill in the fields and click Generate// generate apache redirect & rewrite rules in one click
Generate Apache .htaccess redirect rules, RewriteRule directives, and HTTPS force rules instantly. No coding required — free and browser-based.
^old-page$
/from /to — separated by space or tab
Configure your redirect
Fill in the fields and click GenerateSelect from Simple Redirect, RewriteRule, Force HTTPS, WWW Rules, or Bulk Redirects tabs.
Enter your source path, target URL, and any options like redirect code or flags.
Click Generate, then copy the .htaccess rules and paste them into your server config.
The Apache Redirect Generator creates ready-to-use .htaccess rules for Apache web servers. Choose your redirect type, configure the options, and get copy-paste directives — no need to memorize mod_rewrite syntax.
A 301 is a permanent redirect — search engines transfer link equity to the new URL and update their index. A 302 is temporary — search engines keep the original URL indexed and do not pass link equity. Use 301 for site migrations and permanent URL changes.
No. The simple Redirect and RedirectMatch directives use Apache's mod_alias module, which is enabled by default. Only RewriteRule directives require mod_rewrite and a RewriteEngine On declaration.
Place the .htaccess file in the root of your website (the directory Apache serves from, usually public_html or www). It affects that directory and all subdirectories unless overridden.
The [L] (Last) flag tells Apache to stop processing further rewrite rules if the current rule matches. Without it, Apache continues checking subsequent rules, which can cause unintended double-rewrites.
Use a RewriteCond to check %{HTTPS} is off, then rewrite to https://%{HTTP_HOST}%{REQUEST_URI}. This preserves the full path and query string while upgrading the protocol. Our Force HTTPS tab generates exactly this pattern.
Search engines treat example.com and www.example.com as separate URLs. Having both serve content causes duplicate content issues and splits link equity. Pick one canonical form and redirect the other permanently with a 301.
HTTP Strict Transport Security (HSTS) tells browsers to always use HTTPS for your domain, even if the user types http://. It's recommended for security but be careful: once set with a long max-age, it's hard to undo. Start with a short max-age (e.g. 300 seconds) before going to one year.
Yes. You can combine as many Redirect, RedirectMatch, and RewriteRule directives as needed. Use our Bulk Redirects tab to generate multiple rules at once. Just ensure RewriteEngine On appears before any RewriteRule directives.
Managing URL redirects on an Apache web server typically means writing .htaccess directives by hand — with easy-to-mistype regex patterns and flags that can silently misbehave. This Apache Redirect Generator removes that friction. Select a redirect type, configure your paths, and receive copy-ready .htaccess code in seconds.
💡 Looking for premium web development assets? MonsterONE offers unlimited downloads of templates, UI kits, and developer resources — worth checking out.
Apache offers two primary modules for redirects: mod_alias and mod_rewrite. Understanding the difference helps you choose the right tool for each job.
mod_alias provides the simple Redirect directive. It matches a static path prefix and sends the browser to a new URL. It's fast, easy to read, and requires no regex knowledge. Perfect for straightforward one-to-one URL changes.
mod_rewrite provides RewriteRule — a powerful, regex-based engine. You can match dynamic URL patterns, capture groups, inspect server variables with RewriteCond, and construct target URLs programmatically. It's the right choice for complex URL transformations like removing file extensions, restructuring URL hierarchies, or routing all traffic through a single entry point.
The redirect status code tells browsers and search engines how to interpret the move:
Redirecting all HTTP traffic to HTTPS is now a baseline security requirement. The recommended approach uses mod_rewrite to check the %{HTTPS} server variable:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
This pattern is preferred over RewriteCond %{SERVER_PORT} 80 because it works correctly behind SSL-terminating load balancers and proxies that set the HTTPS variable even when the backend connection is plain HTTP.
Pair this with an HSTS header (Strict-Transport-Security) to instruct browsers to never attempt HTTP connections for your domain, eliminating the redirect round-trip entirely on subsequent visits. Start with a short max-age (e.g., 300 seconds) during testing before committing to the standard one-year value.
Search engines treat example.com and www.example.com as completely separate domains. Serving content on both creates duplicate content issues and dilutes link equity. Choose one canonical form — most modern sites prefer the naked (non-www) domain — and permanently redirect the other.
The preferred non-www redirect:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
The backreference %1 captures the domain without the www. prefix from the RewriteCond match group.
When relaunching a site or changing CMS platforms, dozens or hundreds of URLs may change simultaneously. Bulk redirect rules protect your SEO by preserving the link equity accumulated on old URLs. Rather than using a long series of individual Redirect directives (which Apache processes linearly), consider combining patterns where possible.
For very large redirect sets (500+ rules), performance improves by placing redirect logic in Apache's main server config or a virtual host configuration instead of .htaccess, since .htaccess files are re-parsed on every request. Some server setups also support RewriteMap for hash-based lookups that are dramatically faster than sequential pattern matching.
RewriteRule flags modify how a rule behaves. The most commonly used flags are:
Beyond the patterns this tool generates, here are common scenarios you may encounter:
/about.html to /about using RewriteRule ^(.+)\.html$ /$1 [R=301,L]/blog/ to /articles/ using a prefix match.RewriteCond %{REMOTE_ADDR} or GeoIP-based conditions before a deny rule.ErrorDocument 404 /404.html — not a redirect but a crucial companion rule.