Build a clean, ready-to-use .htaccess file without memorizing Apache rules. Tick the options you need, add your redirects, and copy or download the finished file. Everything runs in your browser, so nothing you enter is sent to our server.
What this tool can do
- Force HTTPS: redirect every http:// visit to https:// with a single 301 redirect.
- WWW or non-WWW: pick one version of your domain so search engines see a single site.
- 301 and 302 redirects: paste your old and new URLs, one per line.
- Browser caching: tell visitors’ browsers to keep images, CSS, JavaScript and fonts, so repeat visits load faster.
- Gzip compression: shrink HTML, CSS, JavaScript and JSON files before they are sent.
- Security rules: disable directory listing, protect wp-config.php and .htaccess, block xmlrpc.php, add security headers, stop image hotlinking, and block IP addresses or bad bots.
- WordPress rewrite block: keep pretty permalinks working with the standard WordPress rules.
How to use the .htaccess generator
- Choose the options you need on the left. The code on the right updates as you go.
- If you want redirects, enter one per line, for example
/old-page /new-page. - Click Copy code or Download .htaccess.
- Connect to your site with FTP or your hosting file manager and open your site’s root folder (usually public_html).
- Save a copy of your existing .htaccess first. Then replace its contents with the new code.
- Visit your site and test the pages and redirects you changed.
Before you replace your .htaccess
A small mistake in .htaccess can show a 500 Internal Server Error across your whole site. Always keep a backup. If something breaks, upload your backup again and the site comes back right away.
A few rules to be careful with:
- HSTS tells browsers to use HTTPS only. Turn it on only after HTTPS works on every page and subdomain.
- Block xmlrpc.php stops brute-force and pingback abuse, but it also breaks Jetpack and the WordPress mobile app.
- Force HTTPS needs a valid SSL certificate. You can check yours with our SSL Certificate Checker.
Frequently asked questions
What is a .htaccess file?
It is a configuration file used by Apache and LiteSpeed web servers. It controls redirects, caching, compression and access rules for a website without editing the main server settings.
Where is my .htaccess file in WordPress?
It sits in the root folder of your WordPress install, next to wp-config.php. It is a hidden file, so turn on “show hidden files” in your FTP client or file manager.
Will this work on Nginx?
No. Nginx does not read .htaccess files. This tool is for Apache and LiteSpeed hosting, which covers most shared WordPress hosts.
How do I redirect one page to another?
Add a line such as /old-page /new-page in the Redirects box. A 301 (permanent) redirect is used by default. Add 302 at the end for a temporary one.
How do I force HTTPS in WordPress?
Tick Force HTTPS and copy the code to your .htaccess file. Your site also needs an SSL certificate, and your WordPress and Site URL settings should start with https://.
Does .htaccess caching speed up my site?
Yes. Browser caching lets returning visitors reuse files they already downloaded, and Gzip makes the files that are sent smaller. Both help page speed.
Is my data stored?
No. The generator works in your browser and does not save or send what you enter.
