Smart Deals - promotions, discount codes and sales

Htaccess Generator

Fast, accurate and free online htaccess generator tool running directly in your browser.

Secure (SSL)
Client-Side Processing
100% Free
Instructions
  • 1
    Enter data
    Enter content, paste text or load a file from disk.
  • 2
    Click the button
    The tool will immediately process your data in the browser.
  • 3
    Get the result
    Copy the finished text or save the file to your device.
function runTool() {
  return "Result ready in 0.1s";
}

.htaccess Premium Generator

Secure and optimize your Apache server in seconds.

Active rules 30
File size 1.47 KB
Format Apache / Litespeed
Base configuration
Security & SEO
Performance & Advanced
LIVE PREVIEW
#####################################################
# Generated by: Premium .htaccess Generator
# Data: 2026-08-30 22:52:15
#####################################################

# Force UTF-8 encoding
AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

</IfModule>

# Kompresja GZIP/Brotli
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/plain text/css text/xml text/javascript application/javascript application/json application/xml image/svg+xml
</IfModule>

# Browser Cache (Lepsze PageSpeed)
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 month"
  ExpiresByType image/x-icon "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/pdf "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
</IfModule>

# Disable directory previews
Options -Indexes

# Block sensitive files
<FilesMatch "(^#.*#|\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|swp)|~)$">
  Require all denied
</FilesMatch>

# Security headers
<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set Referrer-Policy "no-referrer-when-downgrade"
  Header always set X-XSS-Protection "1; mode=block"
</IfModule>

Rate this tool:

Related tools

Other tools you may find useful

.htaccess generator - ready file in a few seconds

If you have ever been messing with .htaccess "live" and after one incorrect character you saw a white page or a redirection loop, you know that this file can be both a savior and a saboteur. This generator gives you a safe start: you select options, see a live preview, copy and upload to the server. No guessing, no copying random rules from the Internet.

free online without registration live preview Apache / LiteSpeed SEO + security

.htaccess generator is for websites on Apache and compatible servers (often also LiteSpeed). You can do the most frequently needed things here: force HTTPS, set the version with or without www, enable browser cache and compression, add security headers, hide directory listings, block sensitive files, and in WordPress you can add rules and (optionally) cut off xmlrpc. In practice: less risk, faster implementation and ordered configuration.

What do you get in the output

At the end you have a complete .htaccess file with comments and the date of generation. This is not a "magic snippet", but a full set of rules matched to the selected profile (smart, WordPress or static site) and your switches. You can paste it as a new file or compare it with the current one and transfer parts.

The preview is live, so you can immediately see how the file is growing and how many rules are active. This sounds nit-picky, but in practice it helps not to overdo it: .htaccess is supposed to be specific, not a "holiday tree" with ten versions of the same thing.

Who it's for

For website owners who want to quickly improve SEO and security, but don't feel like figuring out mod_rewrite at night. For developers who need a sensible staging baseline. For people moving their website to a new hosting, where a slight difference in configuration can cause redirects to fail.

And also for you, if you just want an "online htaccess generator" with clear options: click, copy, upload, test. No guessing what is a "must have" and what is risky.

How to use .htaccess generator step by step

This is one of those things that likes a simple process. First, set up the database, then refine the details, and finally add your own rules. Thanks to this, you avoid a situation where one line of "custom" spoils everything and you don't know why.

  1. Select an optimization profile.

    "Smart" is a universal set for most sites. "WordPress" will add typical redirection rules for WP. A "static/HTML page" makes sense when you don't have dynamic routing and just want a quick, lightweight setup.

  2. Set HTTPS and web mode.

    If you have an SSL certificate, forcing HTTPS is standard. You choose the www mode according to the version of the domain you are promoting (www or non-www). The most important thing is one thing: consistency. Mixing variants is messy for SEO and risks duplicate addresses.

  3. Enable performance: cache and compression.

    The browser cache shortens page reloads and compression reduces transfer speeds. In practice: faster performance, often better results in PageSpeed ​​tests and less grinding on slower connections.

  4. Tighten the security.

    Security headers, directory listing locks and protection of sensitive files are things that rarely bother you and often really reduce the risk. With WordPress, you can also cut off xmlrpc (if you don't use features that require it).

  5. Add flavor options: UTF-8, hotlink, 404, trailing slash.

    Forcing UTF-8 is a minor thing, but it likes to "clean up" enc

Install Webp.pl Have the tools in your own pocket!