How to use the .htaccess Generator
- Tick the features you need.
- Add redirects as “from to” pairs.
- Copy the file to your site's root folder — after backing up the old one.
What does this tool do?
.htaccess files configure Apache and LiteSpeed hosting (common on shared hosts and WordPress). Rules are wrapped in IfModule checks so missing modules don't break the site, and sensitive files like .env and .git are blocked when security headers are on. Test on a staging site first.
Everything runs in your browser — nothing you paste is uploaded.
Why use it?
- HTTPS and www rules.
- Bulk redirects.
- Caching and security headers.
Use cases
- Redirect HTTP to HTTPS and choose www or non-www.
- Redirect old URLs after a site redesign.
- Caching, compression and security headers on shared hosting.
Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
A 301 redirect tells browsers and search engines the move is permanent.
Common mistakes
- Editing the live file without a backup — one typo can take the site down.
- Creating redirect loops between www and non-www.
- Using 302 redirects for permanent moves.
Privacy
Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.
Frequently asked questions
Does it work on Nginx?
No, .htaccess is for Apache and LiteSpeed. Nginx uses its own config.
Where do I put the file?
In your site's root folder, often public_html.
Why the IfModule checks?
So rules for missing modules are skipped instead of breaking the site.
Content last updated . See how M2Toolkit works.