Htaccess Redirect Generator
Guide: Htaccess Redirects Explained: 301 vs 302, Forcing https and www on ApacheMake the lines for an .htaccess file that send old addresses to new ones, force https, add or remove www, or move a whole site to a new domain. Choose permanent or temporary, then copy or download the result. It only works on Apache servers, and the tool cannot test the rules on your server, so test every redirect after you save the file.
This file only works on Apache servers. A mistake in .htaccess can make your whole site show an error, so keep a copy of your current file and test the result straight away.
- 301 and 308 are permanent. Browsers and search engines remember them, so test with 302 first if you are not sure.
Put the lines in the .htaccess file in the top folder of your site. The tool does not check your server, so test each redirect in a private window after you save. If a file already exists, add these lines to it instead of replacing it.
Features
- 301, 302, 307 and 308 redirects for single pages
- Always https, with an option for sites behind a CDN or proxy
- Always www or never www
- Send a whole site to a new domain
How to use Htaccess Redirect Generator
- Type the redirects, the old address first and then the new one.
- Choose the type and the extra options.
- Copy the lines or download the file, add them to your .htaccess and test.
Frequently asked questions
Will this work on my server?
Only on Apache, or on a server that reads .htaccess files, such as LiteSpeed. Nginx and many other servers ignore .htaccess and need different rules. Your host must also allow rewrite rules.
What is the difference between 301 and 302?
A 301 says the move is permanent. Browsers and search engines remember it and treat the new address as the home of the page. A 302 says it is temporary. If you are not sure, start with 302, test, and switch to 301 when it works.
Can a mistake break my site?
Yes. A wrong rule can cause a redirect loop or a server error for every visitor. Keep a copy of your current .htaccess, add the new lines and test in a private window. If something goes wrong, put the old file back.
Does it support query strings or wildcards?
No. Each line redirects one path, with or without a trailing slash. Rules that depend on a query string, or that match many pages with a pattern, need to be written by hand.