.htaccess Generator
Generate common Apache .htaccess rules — force HTTPS, redirect www to non-www (or the reverse), and custom 301 redirects.
Free to useNo software to install — works in any modern browser.
No signup neededOpen the tool and start straight away.
Runs in your browserNothing you enter is sent to a server.
Works on mobileSame tool on your phone, tablet or desktop.
How it works
- Enter — type or paste your values or text.
- Get the result — it is worked out in your browser.
- Adjust — change the inputs to compare, or copy the result.
Related tools
View allPrefer to just describe the task? The AI Assistant can convert, compress and resize files from a short instruction.
About .htaccess Generator
The .htaccess file gives instructions to an Apache web server for one folder of a website — most often redirects, forcing HTTPS and tidying up URLs. This generator writes the common rules so you don't have to remember the syntax.
Before you start
.htaccess only works on Apache and servers compatible with it, such as LiteSpeed, which most shared hosting uses. Nginx ignores the file completely; there the same rules go into the server configuration instead. Always download a copy of your existing .htaccess before changing it.
Common rules
Force HTTPS for every page:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Send one old page to a new address:
Redirect 301 /old-page /new-page
RewriteRule in one sentence: RewriteCond lines set a condition, the RewriteRule after them says what to rewrite if the condition matches, and flags in square brackets change the behaviour — R=301 makes it a permanent redirect and L stops processing further rules.
301 or 302?
Use 301 when a page has moved for good; search engines pass its ranking to the new address. Use 302 only for a temporary move, such as a page that is down for a few days.
If something breaks
A "500 Internal Server Error" straight after editing almost always means a typing mistake or a module that isn't enabled — restore your backup copy and add rules one at a time. A page that keeps reloading in the browser ("too many redirects") means two rules are sending visitors back and forth; this often happens when the hosting panel already forces HTTPS and the file does it again. Test with a private browser window so an old cached redirect doesn't mislead you.
Before you start
.htaccess only works on Apache and servers compatible with it, such as LiteSpeed, which most shared hosting uses. Nginx ignores the file completely; there the same rules go into the server configuration instead. Always download a copy of your existing .htaccess before changing it.
Common rules
Force HTTPS for every page:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Send one old page to a new address:
Redirect 301 /old-page /new-page
RewriteRule in one sentence: RewriteCond lines set a condition, the RewriteRule after them says what to rewrite if the condition matches, and flags in square brackets change the behaviour — R=301 makes it a permanent redirect and L stops processing further rules.
301 or 302?
Use 301 when a page has moved for good; search engines pass its ranking to the new address. Use 302 only for a temporary move, such as a page that is down for a few days.
If something breaks
A "500 Internal Server Error" straight after editing almost always means a typing mistake or a module that isn't enabled — restore your backup copy and add rules one at a time. A page that keeps reloading in the browser ("too many redirects") means two rules are sending visitors back and forth; this often happens when the hosting panel already forces HTTPS and the file does it again. Test with a private browser window so an old cached redirect doesn't mislead you.
Rate this tool
Log in to leave a review.