.htaccess generator

Create .htaccess rules for www URLs, HTTPS redirects and Basic authentication.

Inputs and results stay on your device
URL normalization and redirects
Enter only the domain. The www prefix follows your selected setting. Use Punycode for internationalized domains.
Test with 302 first, then switch to 301. Browsers may remember permanent redirects.
Basic authentication

For Apache 2.4 terminating HTTPS directly. For a CDN or reverse proxy, check that service's redirect settings.

Result

Check the input and settings, then run the tool.

Input is not saved. Copy any results you want to keep.

How to use .htaccess generator

  1. 01Choose www normalization, HTTPS redirects and Basic authentication as needed.
  2. 02Enter your domain and the absolute .htpasswd path, then generate the configuration.
  3. 03Copy or save the result. Back up existing settings, test with 302 redirects, then switch to 301 when ready.

About .htaccess generator

Generate basic Apache 2.4 .htaccess rules in your browser. Combine www normalization, HTTP-to-HTTPS redirects and file-based Basic authentication. This tool does not visit your domain or change your server settings.

Choose a canonical www or non-www URLCreate HTTPS redirectsProtect a staging site with Basic authentication

Applying your .htaccess configuration

Place the rules in the site's root .htaccess, before application rewrite rules. Keep a backup and check both HTTP and HTTPS with and without www. Redirects retain the requested path and query string.

Test with temporary 302 redirects before using permanent 301 redirects. Basic authentication requires an existing .htpasswd file outside the public directory and a working HTTPS configuration.

This generator targets Apache 2.4 with direct TLS termination. AllowOverride must permit FileInfo for redirects and AuthConfig for authentication. A CDN or reverse proxy may require different rules.

Create the .htpasswd password file

Frequently asked questions

Which servers are supported?

Apache 2.4 terminating HTTPS directly, with mod_rewrite, mod_ssl, Basic authentication modules and permission to use these directives in .htaccess. This does not configure Nginx or Vercel. CDNs and reverse proxies need HTTPS detection appropriate to that service.

What else does Basic authentication need?

Create a username and password entry with the .htpasswd generator, save it outside the public directory, and enter its absolute server path. Authentication is allowed over HTTPS only. Without HTTPS redirects, HTTP requests receive 403.

Can I use an existing .htaccess file?

Back it up first, then add these rules before WordPress or other application rewrite rules. Resolve overlapping authentication or redirect settings and test on your server. An SSL certificate must already be configured.

Is my input sent or stored?

Input and generation stay in your browser. Input is not transmitted or persisted, and this page does not load advertising or analytics scripts.

Is it free to use?

Yes. All tools are free, with no account required.