.htaccess Generator
Build redirects and common Apache rules visually — copy or download your .htaccess file.
Redirect all HTTP requests to HTTPS automatically.
Canonicalise your domain to always use (or not use) www.
Compress HTML, CSS, JS, and other text assets to improve load time.
Block browsers from seeing folder contents when no index file exists.
Set long-lived cache headers for images, CSS, and JS files.
Deny access to .env, .git, composer files, and other sensitive paths.
Serve a custom page when a URL is not found.
# .htaccess
How to Use
- Redirects tab — add rows with a From path (e.g.
/old-page), a To URL, and a redirect type (301 = permanent, 302 = temporary). - Common Rules tab — toggle individual rules on or off. Some rules reveal extra options when enabled.
- The generated .htaccess output updates live as you make changes across both tabs.
- Click Copy or Download to get the file, then place it in your Apache site's root directory (or the relevant subdirectory).
- Use a 301 redirect for permanent URL changes (search engines will update their index) and 302 for temporary ones.
About this .htaccess Generator
.htaccess is a configuration file used by the Apache web server to control behavior for a specific directory — redirects, access rules, HTTPS enforcement — without needing access to the main server configuration.
Common uses
- Forcing HTTPS: redirecting all HTTP traffic to the secure HTTPS version of a site
- WWW vs. non-WWW: standardizing on one version of a domain to avoid duplicate-content issues and broken bookmarks
- Custom redirects: sending visitors from an old URL to a new one after a page moves or a site restructures
- Custom error pages: showing a branded 404 page instead of the server's default error page
Why file placement and order matter
.htaccess only works on servers running Apache (not Nginx, which uses a different configuration approach entirely), must be placed in the correct directory to take effect, and rules are typically processed in the order they appear — an incorrectly ordered redirect rule can create an infinite redirect loop.
A word of caution
A syntax error in .htaccess can take down an entire site or directory immediately, since the server fails to process requests correctly. Always back up the existing file before editing, and test changes on a staging environment when possible before applying them to a live site.