NEW CASE
Antana

We create digital solutions that work for businesses


Give us a call +38 (066) 35-14-529

Let's take the first step towards your website — write to us

Close
Tools

301 Redirect Generator

Rules for .htaccess and Nginx: pages, www, HTTPS.

.htaccess

    

Place the rules at the top of the file, before other directives. Always verify the result with our redirect checker: a single mistake in a rule can put the whole site into an infinite loop.

Where the rule goes

It depends on the server. The same redirect is written differently on each.

Apache The .htaccess file in the site root. Rules take effect on save, with no restart needed.
Nginx The server block in the config. Reload the server afterwards or the rule will not apply.
PHP A Location header in code. Useful without config access, but slower than a server rule.
CMS WordPress and similar have redirect plugins. Convenient, but every rule costs a database query.

When you need a redirect

A page URL changed Without a rule the old URL returns 404, taking its rankings and inbound links with it.
Moving to https Both versions must point to one. Otherwise Google sees two sites with identical content.
With or without www Pick one form and redirect the other. Which one does not matter; having both does.
Merging pages Two similar pages compete with each other. Merging the content and adding a 301 beats keeping both.
Moving to a new domain Every old URL should point to its matching new one, not all of them to the homepage.

What to check afterwards

The code really is 301 Some modules default to 302. The page opens but no equity is transferred.
No chain The old URL should point straight at the final page, not through two intermediate hops.
Parameters survived The rule must not strip UTM tags, or the traffic source vanishes from analytics.
No loop A rule pointing at itself creates an endless redirect. The browser gives up after a few tries.

FAQ

Why 301 rather than 302?
301 means “moved permanently”: the search engine passes the accumulated authority to the new URL and eventually drops the old one. 302 says “temporarily” — the old URL stays primary and rankings do not transfer. The costliest migration mistake is using 302 instead of 301 and then wondering why traffic collapsed.
How do I avoid an infinite loop?
A loop happens when a URL redirects to itself or two rules point at each other. We skip lines where the old and new URLs match and warn you about it. Still, verify after deployment: open the site in a private window, then run a few URLs through our redirect checker. More than two hops in a row means something is wrong with the rules.
Where exactly do I paste the rules?
On Apache, into the .htaccess file in the site root, right at the top, before the CMS rules. Create the file if it does not exist. On Nginx the rules go inside the server block of the configuration, and after the change you need to reload the server with nginx -s reload. Always back up the file first: a syntax error in .htaccess takes the whole site down with a 500 error.
Telegram Viber Call us