online

.htaccess Generator β€” online

Generate Apache .htaccess rules for redirects and security.

# Generated by ToolHQ .htaccess Generator
Options -Indexes

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # Force HTTPS
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# Enable Gzip compression
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript
</IfModule>

# Browser caching
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
</IfModule>

How to use .htaccess Generator

1

Select Your .htaccess Rule Type

Click the 'Rule Type' dropdown menu at the top of the interface and choose from Redirects, Security Headers, URL Rewriting, or Cache Control. Each option displays specific configuration options below.

2

Configure Your Rule Parameters

Enter your settings in the input fields. For redirects, paste your source URL in the 'From URL' field and destination in the 'To URL' field. For security, toggle options like 'Block Access', 'Force HTTPS', or 'Disable Directory Listing' using the checkbox controls.

3

Customize Advanced Options

Click 'Advanced Settings' to add response codes (301, 302, 307), specify redirect conditions, or set expiration headers. Use the checkboxes to enable RewriteCond rules for conditional redirects.

4

Generate Your .htaccess Code

Press the blue 'Generate .htaccess' button. Your Apache configuration code appears in the code editor panel on the right side of the screen.

5

Copy and Deploy Your Code

Click the 'Copy Code' button to copy all generated rules to your clipboard. Paste the code into your .htaccess file in your website's root directory using FTP or your hosting control panel's file manager.

Frequently Asked Questions

Related Tools