Home Free tools Redirect generator

301 redirect generator for .htaccess and nginx

Check the redirects you need and get ready-to-paste 301 rules for .htaccess or nginx. Preferred domain, HTTPS, moved pages and domain changes.

Server
Required for nginx: the preferred domain is set up with separate server blocks
Code for .htaccess

                        
                        

Back up the file before editing, then test the old URLs in an incognito window.

Which redirects your site needs

To a search engine, example.com, www.example.com and http://example.com are three different sites with the same content. Redirects merge them into one URL so rankings and backlinks aren’t split between duplicates.

HTTPS and the preferred domain

The bare minimum for any site: every HTTP request and every request to the “wrong” www or non-www version goes to one URL. The generator does it in a single hop, without a chain.

Duplicate pages

/page and /page/, double slashes, index.php in the URL: one page to a visitor, different pages to a crawler. Pick one format and redirect the rest to it.

Domain moves and new site structure

Changed your domain or section URLs? Redirect old pages to new ones. That way you keep your rankings, bookmarks and traffic from ads and social media.

How to add the code to your site

If your site runs on a builder like Wix or Squarespace, you can’t access .htaccess: HTTPS and the preferred domain are set in the domain settings, and page redirects in the site settings.

Apache: the .htaccess file

Open .htaccess in your site’s root folder over FTP or in your host’s file manager. Paste the code at the top, before the CMS rules, and save.

nginx: the site config

Domain server blocks go next to the main one, page rules go inside the main server block. Then run nginx -t and reload.

Testing

Open the old URLs in an incognito window. In developer tools on the Network tab, you should see a 301 status and a single hop.

Your traffic is tagged. Now turn it into leads

A LeadForms quiz asks visitors a few questions and collects their contact details along with the answers. UTM parameters are saved with every lead, and quiz progress shows up as events in Google Analytics 4.

UTM tags in every lead

Source, campaign and ad arrive with the contact details in your email, Telegram, Kommo, Bitrix24 or via webhook.

Google Analytics 4 events, no code

Paste your measurement ID into the quiz settings and track progress with events: opened the quiz, started answering, submitted their details. How to connect it.

A quiz in 10 minutes

Ready-made templates for your industry, or an AI draft based on a description of your business. Your first 20 leads are free, then pick a plan.

Create a quiz for free

Other free tools

Free and no sign-up required, just like this generator.

Frequently asked questions

A 301 is a permanent move: search engines pass the old page’s rankings to the new one and eventually drop the old URL from results. A 302 is temporary: the old URL stays in the index. To change URLs, switch to https or merge domain versions, you need a 301, and that is what this generator builds.
Into the .htaccess file in your site’s root folder, at the very top, before your CMS rules. If the file already has a RewriteEngine On line, uncheck “Wrap in a mod_rewrite block” and paste the rules below that line. Save a backup of the file before you edit it.
The server blocks that merge domain versions go next to the main server block in your site config. All other rules go inside the main server block. After editing, test the config with nginx -t and reload nginx.
Search engines don’t care. What matters is picking one version and redirecting everything else to it. Usually you keep the URL that already shows up in search results and in your ads.
This usually happens with an https redirect when the site sits behind a proxy or a CDN: the server can’t see that the request is already secure. Remove the rule and turn on the https redirect in your hosting or CDN dashboard instead. Another common cause is the same rule in both .htaccess and your CMS settings.
Open the old URL in an incognito window: the browser should jump straight to the new one. You can see the response code in your browser’s developer tools on the Network tab. It should be a 301 with a single hop, not a chain.

Still have questions? Write to us

Name *
* Required field
Email *
* Required field
Message
Write to us!
We reply within 30 seconds