URL Rewriting Tool
Convert URLs to SEO-friendly format
Examples
htaccess Rewrite Rules Generator Online
The htaccess rewrite rules generator from VSM lets you build precise RewriteRule and RewriteCond directives in seconds — just enter a source pattern and destination URL, choose between a 301 redirect, 302 redirect, or silent rewrite, and receive ready-to-paste .htaccess code compatible with Apache and LiteSpeed servers.
Benefits of the htaccess rewrite rules generator
- Generates syntactically correct mod_rewrite directives without requiring you to remember regex flags or Apache documentation.
- Supports permanent 301 and temporary 302 redirects, preserving SEO equity when you restructure URLs.
- Produces transparent rewrites that serve different backend content while keeping the original URL visible in the browser.
- Validates your regex pattern client-side before you deploy, catching mistakes like unescaped dots or missing anchors early.
- Completely free, no sign-up required, and runs entirely in the browser — your URL data never leaves your device.
Use cases for htaccess URL rewriting
- Force HTTP to HTTPS sitewide with a single
RewriteCond %{HTTPS} offrule block. - Remove
.phpor.htmlfile extensions to create clean, SEO-friendly URLs like/aboutinstead of/about.php. - Redirect www to non-www (or vice versa) to eliminate duplicate-content penalties in Google Search Console.
- Create short vanity URLs for marketing campaigns that internally map to long query-string URLs.
- Route all traffic to
index.htmlfor single-page applications (React, Vue, Angular) served from Apache or LiteSpeed. - Block specific bots or IP ranges using RewriteCond conditions on
HTTP_USER_AGENTorREMOTE_ADDR.
How to use the htaccess rewrite rules generator
- Enter the source pattern in the first field — plain text like
old-pageor a full regex like^products/(.*)$. - Enter the destination URL or internal path, using back-references like
new-products/$1when needed. - Select the rule type: 301 Redirect, 302 Redirect, or Rewrite (invisible to the browser).
- Click Generate to produce the complete
.htaccessblock, including the requiredRewriteEngine Online. - Copy the output and paste it into the
.htaccessfile in your website's document root, then test in an incognito window.
Frequently asked questions
Do these rules work on LiteSpeed servers? Yes. LiteSpeed natively parses .htaccess and fully supports mod_rewrite syntax, so the generated rules deploy without modification on LiteSpeed hosting.
What is the difference between a 301 redirect and a transparent rewrite? A 301 tells both the browser and search engines to permanently update the URL; a transparent rewrite serves different content internally while the address bar still shows the original URL — the visitor and crawler never see the backend path.
Can I stack multiple rules in one .htaccess file? Absolutely. Copy each generated block and append it below the previous one, making sure RewriteEngine On appears only once at the top of the rewrite section.
Will a rewrite rule slow down my site? The performance impact is negligible for typical rule sets. Apache and LiteSpeed compile .htaccess rules into memory on first access, so matching overhead is minimal compared to a round-trip database query.