Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper tools.htaccess Redirect Generator
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский

.htaccess Redirect Generator

dev

Paste old and new URLs and get 301 rules for .htaccess or Nginx, checked for loops

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.

A 301 redirect tells browsers and search engines that a page has moved for good. In Apache's .htaccess, RewriteRule ^old-page$ /new-page [L,R=301] sends /old-page to /new-page; in Nginx, location = /old-page { return 301 /new-page; } does the same. Use 302 or 307 for a temporary move and 410 for a page removed on purpose.

Next:
  • Nginx Config Generator A commented nginx server block for a reverse proxy, static site, SPA or redirect

How to create 301 redirects in .htaccess

1

Paste one redirect per line into the Redirects box: the old path, a space, then the new path or URL.

2

Choose Apache or Nginx, and turn on Force HTTPS or pick www or no www if you want those too.

3

Fix any line marked as a loop, and accept the offer to shorten chains so each visitor makes one hop.

4

Click Copy or Download, and add the rules to the top of your .htaccess file or your server block.

About the .htaccess Redirect Generator

Paste one redirect per line, the old address and then the new one, and the rules are written as you type. Old addresses can be paths or full URLs copied from a browser or an analytics export; tabs, commas and arrows also work, so a spreadsheet column pair pastes straight in. Add a code at the end of a line to override the default, or write 410 instead of a new address for a page that is gone.

Which code.

Code Meaning Use it for
301 Moved permanently Renamed pages, a new domain, HTTPS
308 Permanent, same method APIs and forms that POST
302 / 307 Temporary Campaigns, maintenance, A/B tests
410 Gone Pages removed on purpose

Apache. Every rule uses mod_rewrite. The simpler Redirect directive matches prefixes, so Redirect /shop /store also catches /shopping, and mixing the two modules runs them in an order that surprises people. Patterns are anchored and escaped, so a dot in old.html matches only a dot. An old address with a query string, such as /products?id=42, gets its own RewriteCond and the query is dropped from the new address.

Nginx. Each page gets an exact location = block with return. HTTPS and the www choice get their own server blocks, which need your domain.

Checks. A rule that sends a page to itself, directly or through other rules, is a loop and is left out. A rule that points at another redirected page is a chain; one click points it straight to the final page, so visitors and crawlers make one hop instead of several. A repeated old address is flagged, because only the first rule would ever run.

HTTPS and the host are handled in one hop, before the page rules. Test with 302 first: browsers remember a 301 for a long time.

Everything runs in your browser; nothing you paste is sent anywhere.

Frequently asked questions

How do I redirect one page to another in .htaccess?

Add RewriteEngine On once, then one line per page: RewriteRule ^old-page$ /new-page [L,R=301]. The pattern has no leading slash in .htaccess, the caret and dollar make it match only that exact page, and R=301 makes the move permanent. Place the rules near the top of the file, before any WordPress or framework block.

What is the difference between 301, 302, 307 and 308 redirects?

301 and 308 are permanent: search engines move the old page's ranking to the new address. 302 and 307 are temporary, so the old address stays indexed. 307 and 308 also require browsers to repeat the same method, such as POST, while 301 and 302 allow a switch to GET. Most page moves should use 301.

How do I redirect HTTP to HTTPS and www to non-www in one step?

Combine the conditions so the visitor makes a single hop: redirect when HTTPS is off or the host starts with www, and send them to https plus the host without www. This generator writes exactly that with three RewriteCond lines and one RewriteRule, or a pair of server blocks for Nginx, instead of two separate redirects in a row.

Why does my .htaccess redirect cause a redirect loop?

A loop happens when a rule sends a page to an address that the same or another rule redirects back. Common causes are redirecting /page to /page/ while another rule strips the slash, or forcing HTTPS behind Cloudflare Flexible SSL, where the server always sees HTTP. This tool refuses rules that loop and names the line.

How do I redirect a URL with a query string?

RewriteRule never sees the query string, so match it with a RewriteCond first: RewriteCond %{QUERY_STRING} ^id=42$, then the RewriteRule for the path. Add the QSD flag so ?id=42 is not copied onto the new address. Pasting /products?id=42 /products/blue-mug here writes both lines for Apache, or an if ($args) test for Nginx.

Do redirect chains hurt SEO?

Every extra hop costs a little time, and Google follows at most 10 hops before giving up, so chains waste crawl effort and slow visitors. After a second site move, old addresses often point at pages that were redirected again. This generator spots each chain and rewrites the rule to point straight at the final page in one click.

Sources

  • Apache HTTP Server 2.4, mod_rewrite: RewriteRule and RewriteCondPatterns without the leading slash in .htaccess, the R, L, G, NE and QSD flags
  • Apache HTTP Server 2.4, Redirecting and Remapping with mod_rewriteCanonical host and HTTPS rules
  • nginx, ngx_http_rewrite_module: return and ifreturn with a code and URL, $is_args$args
  • nginx, ngx_http_core_module: locationExact-match location = /path
  • RFC 9110, HTTP Semantics, 15.4 Redirection 3xx and 15.5.11 410 Gone (IETF)301 and 308 permanent, 302 and 307 temporary, 410 removed on purpose

Last verified 16 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about .htaccess Redirect Generator and anybody who knows can answer. No account needed.

Common uses

  • Nginx Redirect GeneratorTurn a list of old and new URLs into Nginx return 301 rules and server blocks
  • 301 Redirect GeneratorGenerate permanent 301 redirects in bulk, with chains shortened and loops caught

Same job, other tools: Open Graph Tag Generator – Generate og:title, og:description, og:image and og:url tags · Google Analytics URL Builder – The five utm parameters GA4 reads, with the naming traps flagged.

On the related tools: Cron Expression Generator – Generate a cron expression by choosing when the job should run.

Related tools

All developer tools
UUID GeneratorRandom v4 and time-ordered v7 UUIDs, up to 1,000 at once, plus a validatorHash GeneratorMD5, SHA-1, SHA-256, SHA-384 and SHA-512 of text or files, with checksum compareCron Expression BuilderBuild a cron schedule from menus, read it in plain English, see the next runsSlug GeneratorClean URL slugs from titles, including accented and Hindi text, one or hundreds at onceMeta Tag GeneratorWrite title, description, canonical, Open Graph and Twitter tags with a live previewRobots.txt GeneratorBuild a robots.txt with presets, then check what every line really doesSitemap GeneratorTurn a list of URLs into a valid sitemap.xml, with an index when it gets too bigUTM BuilderBuild campaign links with source, medium and campaign, then export the lot as CSV
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)