Skip to calculator
Veomark

Free · Instant · No signup

HTACCESS Rewrite Rule Generator

Emit a RewriteRule from a from-path, to-path, and optional 301 flag.

Page updated 2026-09-14.

HTACCESS Rewrite Rule Generator visual
Sponsored

Calculator

Without a leading slash.

Target path or URL.

Sponsored

One redirect, expressed as a working RewriteRule

Redirecting 'old-page' to '/new-page' as a permanent redirect generates: RewriteEngine On followed by RewriteRule ^old-page$ /new-page [R=301,L] -- a complete, ready-to-use Apache rewrite rule.

The ^old-page$ pattern uses regex anchors (^ for start, $ for end) to match the path exactly, rather than matching 'old-page' as a substring anywhere in a longer path -- without those anchors, a rule meant for exactly '/old-page' could unintentionally also match something like '/old-pages-list'.

[R=301,L] does two things: R=301 sends an actual HTTP 301 (permanent redirect) status code to browsers and search engines, and L (last) tells Apache to stop processing further rewrite rules once this one matches, preventing later rules in the same .htaccess file from also trying to act on the already-redirected request.

Why this covers one rule, not a full migration

Single-rule helper. Host redirects and query-string maps need extra flags. This generates one path-to-path redirect. Redirecting an entire domain to a different host, preserving or stripping query strings, or handling a large batch of old-URL-to-new-URL mappings after a site migration all need additional RewriteCond conditions or flags beyond this single RewriteRule.

A 301 (permanent) redirect tells search engines to transfer ranking signals to the new URL and update their index accordingly -- using 301 instead of a temporary 302 matters specifically for SEO when a URL change is meant to be permanent, which is why this generator defaults to offering that choice explicitly.

RewriteEngine On only needs to appear once per .htaccess file, even if you have multiple RewriteRule lines -- if you're adding this generated rule to a file that already has other rewrite rules, you likely don't need a second RewriteEngine On line.

Handling a larger set of redirects

For migrating many old URLs at once (rather than one rule at a time), the Redirect Map (CSV to 301 Rules) Generator is built specifically for that batch case.

If the destination server runs Nginx instead of Apache, the syntax is entirely different -- the .htaccess to Nginx Config Converter translates between the two.

Frequently Asked Questions (FAQ)

What do the ^ and $ symbols in the pattern do?

They're regex anchors: ^ matches the start of the path and $ matches the end, together ensuring the rule matches 'old-page' exactly rather than as a substring within a longer path like 'old-pages-list'.

What does the [R=301,L] flag combination mean?

R=301 sends an HTTP 301 permanent redirect status code to the browser or search engine. L (last) stops Apache from evaluating any further rewrite rules in the file once this one has matched, preventing unintended interaction with later rules.

Should I use 301 or a temporary redirect (302)?

Single-rule helper. Host redirects and query-string maps need extra flags. Use 301 (permanent) when the URL change is meant to be permanent -- it tells search engines to transfer ranking signals to the new URL. Use a temporary redirect only if the old URL might come back into use later.

Do I need a RewriteEngine On line for every rule I add?

No. RewriteEngine On only needs to appear once per .htaccess file to activate the rewrite module, even if the file contains multiple RewriteRule lines below it.

Can this generate redirects for a whole batch of old URLs at once?

No. Single-rule helper. Host redirects and query-string maps need extra flags. This produces one rule for one from/to path pair. For migrating many URLs at once, use a batch-oriented tool like the Redirect Map (CSV to 301 Rules) Generator instead.