Home  ›  Developer Tools  ›  .htaccess Generator

.htaccess Generator
Build Apache .htaccess rules visually – 301 redirects, HTTPS enforcement, www/non-www canonicalization, directory protection, and more – and download the file ready to upload.
✓ Free✓ No signup✓ Privacy first✓ Runs in your browser
.htaccess Generator - ToolPremier
Basic Redirects
Force HTTPS Redirect Redirect all HTTP requests to secure HTTPS
Force WWW prefix Redirect domain.com to www.domain.com
Remove WWW prefix Redirect www.domain.com to domain.com
Performance Optimization
Enable Gzip Compression Compress HTML, CSS, and JS files on load
Enable Browser Caching Leverage Expires headers for static assets
Security Settings
Custom 301 Redirects
Custom Error Pages
IP Blocking
Generated .htaccess File

        

.htaccess Generator · offline generation · 100% private client-side calculations

How it works
Convert in three steps

1. Select your rules

Choose from common .htaccess configurations: redirect HTTP to HTTPS, redirect www to non-www (or vice versa), set up 301 URL redirects, enable Gzip compression, set browser caching headers, or restrict directory access.

2. Configure the details

Fill in the specific values for each rule - source and target URLs for redirects, domain for canonicalization, directory paths for protection.

3. Download the .htaccess file

Get the complete, correctly formatted .htaccess file - upload it to your web root or merge the rules into an existing .htaccess file.

FAQ
Common questions
A .htaccess file (hypertext access) is a configuration file for Apache web servers that controls server behavior at the directory level – without needing access to the main server config. Rules in .htaccess apply to the directory it is placed in and all subdirectories. Common uses include URL redirects, HTTPS enforcement, authentication protection, MIME type configuration, caching headers, and rewrite rules for clean URLs.
.htaccess works on Apache-based hosting – the most common type for shared hosting, cPanel environments, and many WordPress hosts. It does not work on Nginx servers (Nginx uses a different configuration system). If you are unsure whether your host uses Apache or Nginx, check your hosting control panel or contact your host. WordPress on shared hosting typically runs on Apache and supports .htaccess by default.
Use a Redirect 301 rule: Redirect 301 /old-page/ https://yourdomain.com/new-page/. The first path is relative to your site root; the target URL is absolute. For pattern-based redirects (redirecting all pages under /blog/ to /articles/), use RewriteRule with a regex pattern – the generator handles both simple and pattern-based redirect types.
Yes – an error in .htaccess syntax causes a 500 Internal Server Error on Apache. Always keep a backup of your current .htaccess file before making changes, and test on a staging environment first. If your site goes down after uploading a new .htaccess, either delete the file via FTP/file manager or restore your backup. Common mistakes are mismatched RewriteCond and RewriteRule pairs and missing RewriteEngine On directive.
Keep going
Related tools

Robots.txt Generator

Generate the robots.txt file that works alongside your .htaccess.

XML Sitemap Generator

Build the sitemap.xml referenced in your robots.txt.

HTTP Status Code Lookup

Reference 301/302 and other redirect codes used in .htaccess rules.

Regex Tester

Test the regex patterns used in RewriteRule and RewriteCond directives.

About the .htaccess Generator
.htaccess rules are powerful but unforgiving – a single syntax error takes the whole site down with a 500 error. Writing them by hand requires knowing the exact directive syntax, correct flag placement, and the order-of-operations logic for RewriteEngine rules. Most developers reach for a generator rather than writing from memory, which is exactly what this tool is for. Select the rules you need – HTTPS redirect, www canonicalization, specific URL redirects, directory protection, caching headers – fill in the values, and download a correctly formatted .htaccess file. It covers the most common configurations needed on Apache-hosted WordPress sites, static sites, and PHP applications.
Benefits
Privacy
All .htaccess generation runs in your browser. Domain names and URL paths you enter are never transmitted to any server.