.htaccess Generator

Generate .htaccess files for Apache servers. Create redirects, rewrites, security rules, caching headers with a visual rule builder.

Quick Settings

Add Redirect Rule

Preview

# Configure rules above to see preview

Installation Instructions

1

Generate your .htaccess file

Configure rules above and download the generated .htaccess file.

2

Backup existing .htaccess

If you have an existing .htaccess file, make a backup before replacing it.

3

Upload to server root

Upload the .htaccess file to your website's root directory via FTP or file manager.

4

Test your website

Test all rules to ensure they work correctly. If you encounter errors, restore your backup.

Template Support

Pre-built templates for WordPress, Laravel, and Drupal with best practices.

Security Rules

Protect files, block IPs, disable directory browsing, and prevent hotlinking.

Performance

Browser caching and Gzip compression for faster page loads.

Frequently Asked Questions

What is an .htaccess file?

.htaccess (hypertext access) is a configuration file used by Apache web servers to configure website behavior at the directory level. It allows you to control redirects, URL rewrites, security settings, caching, and custom error pages without modifying the main server configuration.

What's the difference between Apache 2.2 and 2.4 syntax?

Apache 2.4 introduced new access control directives. Instead of 'Order Allow,Deny' and 'Deny from all' (2.2), it uses 'Require all denied' (2.4). Always use 2.4 syntax for modern servers as Apache 2.2 reached end-of-life in 2017.

What's the difference between 301 and 302 redirects?

301 is a permanent redirect that tells search engines the page has moved permanently, transferring SEO value to the new URL. 302 is a temporary redirect that doesn't transfer SEO value, used when a page is temporarily unavailable or for A/B testing.

What are RewriteRule flags?

Flags modify RewriteRule behavior. Common flags include: L (last rule, stop processing), R=301 (redirect with 301 status), NC (case-insensitive matching), QSA (append query string to substitution). Multiple flags are separated by commas like [L,R=301,NC].

How do I force HTTPS on my website?

Enable the 'Force HTTPS' option which adds a RewriteRule that checks if HTTPS is off and redirects all HTTP requests to HTTPS. This is essential for security and SEO as Google prioritizes HTTPS sites in search rankings.

Should I enable Gzip compression?

Yes, Gzip compression reduces file sizes by 50-70%, significantly improving page load times and reducing bandwidth usage. Enable it for text-based files (HTML, CSS, JS, XML, JSON) but not for already-compressed formats like images or videos.

How do I protect sensitive files like wp-config.php?

Use the 'Protect Files' security rule to deny access to sensitive files. The generator creates a Files directive that denies all access to specified files, preventing unauthorized access to configuration files, .env files, or other sensitive data.

Can I use .htaccess with Nginx?

No, .htaccess is Apache-specific. Nginx uses different configuration files (usually in /etc/nginx/sites-available/). You'll need to convert .htaccess rules to Nginx syntax or use Apache if your hosting provider allows you to choose the web server.