.htaccess Redirect Generator
Paste your old and new addresses, pick the site-wide rules you need, and get a ready-to-use .htaccess file for Apache or a config snippet for nginx. Bad lines are flagged before they reach your server.
Site-wide rules
Used as hollowtreeworkshop.co.uk.
Redirect type
Used for every rule in the file. Pick 302 while testing, then switch to 301.
One per line: the old path, a space, then the new path or full URL. Lines starting with # are skipped. 6 redirects ready.
.htaccess
# Redirects for hollowtreeworkshop.co.uk, made with the WeblixTools .htaccess Redirect Generator
# Put this file in your site's root folder, next to index.html or index.php.
# 301 = moved for good.
<IfModule mod_rewrite.c>
RewriteEngine On
# Send http:// and www.hollowtreeworkshop.co.uk to https://hollowtreeworkshop.co.uk, in one step
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.hollowtreeworkshop\.co\.uk$ [NC]
RewriteRule ^ https://hollowtreeworkshop.co.uk%{REQUEST_URI} [L,R=301]
</IfModule>
# Page redirects (prefix match: /old also moves /old/anything to /new/anything)
Redirect 301 /oak-tables.html /tables/oak/
Redirect 301 /benches.php /benches/
Redirect 301 /shop/old-catalogue.pdf /downloads/catalogue-2026.pdf
Redirect 301 /blog/our-new-workshop /news/new-workshop/
Redirect 301 /contact-us /contact/
Redirect 301 /summer-sale https://shop.hollowtreeworkshop.co.uk/sale
Checks
Every line looks fine.
Made in your browser
Your URLs and domain stay in this tab. Nothing is sent to us.
Apache and nginx
One list of redirects, two configs, switch with a click.
Errors caught early
Missing targets, loops and bad paths are listed by line number.
Moving pages without losing visitors
When a page moves, anyone who bookmarked the old address, clicked an old link or found it in Google lands on a 404 unless you tell the server where it went. A redirect does that. A 301 says the move is permanent, so search engines pass the old page's standing to the new one and swap the address in their results. A 302 says it's temporary, and the old address stays in the index.
This tool writes those rules for you. Type one redirect per line, old path first and the new path or full URL second, separated by a space. You can paste a long list from a spreadsheet, since tabs count as spaces too. On top of the page redirects you can add three site-wide rules: send http to https, pick www or non-www as the main host, and add or remove the slash at the end of addresses.
The output switches between Apache, which reads a file called .htaccess in your site's root folder, and nginx, which uses server and location blocks in its config. Everything is built in your browser as you type, and nothing you enter is sent anywhere.
How to use it
- 1Enter your domain, for example example.com, without https:// or a path.
- 2Choose 301 or 302, and switch on the https, www and trailing slash rules you want.
- 3Paste your redirects, one per line, like /old-page /new-page.
- 4Fix anything listed under Checks. Lines with errors are left out until you do.
- 5Pick Apache or nginx, then copy the result or download it as .htaccess or nginx.conf.
What gets written for each server
- Apache, site-wide rules: a RewriteEngine On block with RewriteCond and RewriteRule lines, wrapped in <IfModule mod_rewrite.c>. The domain is escaped for the pattern, so example.com becomes example\.com.
- Apache, https plus www: both are handled by one rule with an [OR] condition, so http://www.example.com goes to https://example.com in a single hop rather than two.
- Apache, page redirects: Redirect 301 /old /new lines. Switch on exact matching and you get RedirectMatch 301 ^/old/?$ /new instead, with dots, brackets and other regex characters in the path escaped.
- nginx, site-wide rules: separate server blocks that return 301 for port 80 and, when you choose www or non-www, for the other host on port 443.
- nginx, page redirects: a location = /old block with return 301 for each line, placed inside your main server block.
- Trailing slash: a rewrite rule that adds or removes the final slash. On Apache, real files are skipped when adding and real folders when removing. Both servers skip addresses with a file extension, like /feed.xml, when adding.
Prefix match or exact match on Apache
Apache's plain Redirect line matches the start of the address. Redirect 301 /blog /news moves /blog, and it also moves /blog/my-post to /news/my-post. That's handy when a whole folder changes name, and a nasty surprise when you only meant one page.
It can also loop. If /blog points to /blog/archive, the new address starts with /blog, so Apache would redirect it again. The checks warn you about that, and about redirecting / on its own, which would catch every page on the site. Turn on exact matching to fix both: RedirectMatch only moves the path itself, with or without a trailing slash. The nginx output always uses exact matches.
What the checks catch
- A line with no new address after the old one.
- An old path that doesn't start with /, or a full URL where only the path belongs.
- Old and new addresses that are the same, including a full URL on your own domain that points back to the same path.
- An old path with a ?query or #fragment, which these rules can't match.
- The same old path listed twice, more than two parts on a line, or a $ in the new URL, which both servers read as a variable.
Before you upload
Keep a copy of your current .htaccess and add the new lines to it rather than replacing it, especially on WordPress, which keeps its own rules in the same file. Put the redirects above the WordPress block. On nginx, run sudo nginx -t before reloading so a typo doesn't take the site down.
Test with 302 first if you're unsure. Browsers remember 301s for a long time, so a wrong permanent redirect can stick in your own browser even after you've fixed the file. Once the result looks right, switch to 301.
Related tools
What Our Users Say
Real feedback from people using WeblixTools, checked by our team before it appears.
5.0 out of 5 · 1 review
very nice
Frequently Asked Questions
Where do I put the .htaccess file?
In the root folder of your site, the one that holds index.html or index.php. It's often called public_html or www on shared hosting. If a .htaccess file is already there, open it and paste the new lines in rather than overwriting it.
My download is called htaccess without the dot. Is that a problem?
Some browsers and operating systems drop the leading dot because files starting with a dot are hidden. Rename it to .htaccess after uploading it to your server, or copy the text and paste it into the file in your host's file manager.
Should I use 301 or 302?
Use 301 when the page has moved for good, which is almost always the case after a redesign or a domain change. Use 302 for something short-lived, like sending a product page to a sale page for a week. The choice applies to every rule in the file.
Will the https rule work behind Cloudflare or a load balancer?
Not always. If a proxy handles https and talks to your server over plain http, Apache sees %{HTTPS} as off on every request and the rule loops. In that case turn on the proxy's own Always Use HTTPS setting and leave the https option off here.
Can I redirect to a different domain?
Yes. Write the full URL as the new address, like /summer-sale https://shop.example.com/sale. Relative targets such as /new-page stay on the same site.
Why are some of my lines missing from the output?
Lines with an error are left out so they can't break the file. Look under Checks: each problem is listed with its line number. Blank lines and lines starting with # are skipped on purpose, so you can keep notes in your list.
Does the www option need my domain?
Yes, because the rule has to name the host to send visitors to. If the domain field is empty or doesn't look like a domain, example.com is used as a stand-in and a warning tells you so. The nginx output needs it for server_name too.
Is my list of URLs stored anywhere?
No. The checks and both configs are built by code running in your browser, and nothing you type is sent to our server.