Skip to content
zefıly

Redirect rule generator for nginx and .htaccess

Enter the old path and the new address, pick 301 or 302, and get the nginx and .htaccess rules side by side. Presets add an HTTPS redirect and a www to non-www redirect, with the regular expressions escaped for you.

nginx (inside a server block)

        
.htaccess (Apache, OpenLiteSpeed)

        

Runs in your browser. Nothing you type here is sent to Zefily or stored.

How to use it

  1. 1

    Enter the old path, such as /old-page, and the new address, such as /new-page or https://example.com/new-page.

  2. 2

    Choose 301 for a permanent move or 302 for a temporary one. Add the HTTPS or www presets if you need them.

  3. 3

    Copy the nginx block into your server block, or the .htaccess lines into the site folder, then test the redirect.

Questions

Should I use a 301 or a 302 redirect?

Use 301 for a permanent move. Browsers and search engines move the old address to the new one. Use 302 for a temporary change, such as maintenance or a test, so the old address stays the official one.

Why does the tool escape some characters?

In .htaccess the path is a regular expression, so a dot or a question mark must be escaped with a backslash to match literally. nginx exact locations match the text as written, so the tool accepts only letters, digits, dots, dashes, underscores, tildes, percent signs and slashes in paths.

Where do the nginx and .htaccess rules go?

Put the nginx location inside the server block of the site, then run nginx -t and reload nginx. Put the .htaccess lines in the .htaccess file of the site document root, on a stack that reads .htaccess such as Apache or OpenLiteSpeed.

Do the www and HTTPS redirects need a certificate?

Yes. The host you redirect from must serve HTTPS first, or browsers show a certificate warning before the redirect happens. The HTTPS guide explains how certificates are set up for each site and each alias.

Zefily does this for you on your servers

Connect a server and Zefily sets up cron jobs, permissions, redirects, PHP pools and robots rules for your sites, then keeps them in place.

Start free

Black Friday & Cyber Monday

Before you go: lifetime plans are on sale

Pay once for a lifetime plan, or get 30% off the first year of any yearly plan.

Only 100 lifetime plans per plan. When they are gone, they are gone.

See the campaign

Amazing November

See the campaign →