Skip to main content

.htaccess Generator

Generate an .htaccess file for Apache: force HTTPS, set redirects, error pages, caching, compression and security headers. Private.

More options

Redirect a page

Error page

.htaccess

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Free Online .htaccess Generator

Choose what your Apache site needs and get a ready .htaccess file: send visitors to HTTPS, redirect old pages, show your own error pages and let browsers cache files. It gives developers a quick browser-based way to solve a focused .htaccess generator task before moving the result into a project.

How to make an .htaccess file

Switch on the options you need. Add redirects and error pages below. Copy the result, or download it and upload it to your site's root folder as .htaccess.

Testing it

Open your site in a private window after uploading. If you get a 500 error, rename the file and check the Apache error log: a module may be missing.

Common mistakes

  • Writing redirect loops, such as forcing www and non-www at the same time.
  • Forcing HTTPS before a certificate is installed: visitors then see a security error.

Frequently asked questions

Where do I put the .htaccess file?
In the root folder of your website (next to index.html), or in a subfolder to apply only there. The file name starts with a dot and has no extension.
Why does nothing happen?
Your host must allow overrides (AllowOverride All) and have the modules turned on: mod_rewrite, mod_expires, mod_deflate and mod_headers. Shared hosting usually does; on your own server check the Apache config.
Will it work on Nginx?
No. Nginx ignores .htaccess files. Use the Nginx Config Generator instead.
Which redirect code should I use?
301 for a page that moved for good (search engines transfer ranking) and 302 for a temporary move. 307 and 308 do the same but never change POST to GET.
How do I use this .htaccess generator tool?
Use the interactive controls above; processing stays in your browser and the result is intended as a practical starting point for development work.

More DevOps & Network

View all DevOps & Network tools →