This htaccess redirect generator creates ready-to-use .htaccess code for Apache and LiteSpeed hosting, including Hostinger. You tick the options you need, add your redirects, and download the file. It suits site owners who want to force HTTPS, choose www or non-www, or move old pages without writing rules by hand.
How to use the .htaccess generator
- Tick the options you need. Choose from HTTPS, www handling, caching and gzip compression.
- Add your redirects. Enter each old page and the new address it should send visitors to.
- Download the file. The tool gives you the finished rules as a file.
- Rename it to .htaccess. The name must start with a dot and have no extra extension.
- Upload it to your site. Put it in the root folder of your website, usually the same place as your main index file.

Need to go a step further? The Robots.txt Generator and the Meta Tag Generator work the same way, right in your browser.
Before you upload anything, save a copy of the .htaccess file already on your server. That copy is your quickest way back if something goes wrong.
What is an htaccess generator good for?
An .htaccess file holds instructions that Apache and LiteSpeed servers read for your site. Writing those instructions from memory is easy to get wrong. A generator gives you a clean starting point, so you only decide what you want to happen.
- Moving to HTTPS. After installing an SSL certificate, you can send all visitors to the secure version of every page.
- Picking one address. Choose whether your site lives at www.example.com or example.com, and send the other version to it.
- Replacing old pages. If you deleted a page or changed its URL, a 301 redirect sends visitors and search engines to the new one.
- Speeding up pages. Caching and gzip rules help browsers store files and download smaller ones.

How do I set up an htaccess 301 redirect?
A 301 redirect tells browsers and search engines that a page has moved for good. In the tool, add the old address and the new address as a pair. Repeat for each page you have moved, then download the file.
A practical example: you renamed /old-pricing/ to /plans/. Add that pair, and anyone using an old bookmark or search result lands on the right page instead of an error.
Always point each old page to the most relevant new page. Sending everything to the home page confuses visitors and gives search engines little reason to treat the new page as a replacement.
How do I force HTTPS and choose www or non-www?
For a force HTTPS htaccess setup, tick the HTTPS option. For the www rule, pick whether to add www or remove it. Do both in one file so every version of your address ends up in one place.
Choose one style and stay with it. If your links, sitemap and social profiles all use example.com, then removing www is the tidy choice. If you already use www everywhere, add it instead. Setting up an htaccess redirect from www to non-www takes one tick, but the choice itself should match what you already publish.
Make sure your SSL certificate is active before you force HTTPS. Without it, visitors may see a security warning instead of your site.
Which options should you pick?
| Option | What it does | Use it when |
|---|---|---|
| HTTPS | Sends visitors to the secure version of your site | Your SSL certificate is installed |
| www rule | Adds or removes www in your address | You want one main version of your domain |
| 301 redirects | Sends old pages to new ones permanently | You moved, renamed or merged pages |
| Caching and gzip | Helps browsers store files and load smaller downloads | You want a faster site |
Tips for best results
- Back up first. A single typo in .htaccess can make your site show an error until it is fixed.
- Avoid redirect chains. If page A goes to B and B goes to C, send A straight to C.
- Use full, exact addresses. Check spelling and slashes in both the old and new URL.
- Test after uploading. Open your home page, a redirected page and the http version of your site in a private browser window.
- Merge with care. If your server already has an .htaccess file with other rules, such as WordPress settings, copy the new rules in rather than replacing the whole file.
Common problems and quick fixes
The site shows an error after upload
Restore your backup copy of .htaccess. Then compare it with the new file to find the line that caused the trouble.
The file does not seem to work
Check the name. It must be exactly .htaccess and sit in your site's root folder. Also confirm your host runs Apache or LiteSpeed, since Nginx servers do not read .htaccess files.
A redirect still shows the old page
Your browser may have saved the earlier result. Clear the cache or test in a private window.
You cannot see the file on your server
Files starting with a dot are often hidden. Turn on the hidden-files setting in your file manager or FTP program.
Is your data private?
The tool runs in your browser, so nothing you enter is uploaded. It is free to use, and you can generate as many files as you need.
How do I use the htaccess redirect generator?
Choose the rules you need, such as forcing HTTPS, adding or removing www, or a 301 redirect from an old page. The htaccess redirect generator writes the code; copy it into the .htaccess file in your site’s main folder and test the old address.
