Config Files · 1 file

Sample .htaccess File

Apache .htaccess files configure rewrites, redirects and caching per directory. Our sample is realistic and valid for its tool, with fake hosts and secrets.

.htaccess · 714 B

Apache .htaccess

An Apache .htaccess with HTTPS and www redirects, a front-controller rewrite, caching and compression rules and a blocked directory. All hosts, keys and secrets are fake.

CC0 · free for any use · Verified by an independent tool · Report a problem

.htaccess — first linesApache
# Sample Apache .htaccess — samplefiles.com
RewriteEngine On

# Force HTTPS and strip www
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301]

# Send everything that isn't a real file to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json
</IfModule>

Options -Indexes
RedirectMatch 403 ^/\.git

File details

Size
714 B (714 bytes)
MIME type
text/plain
SHA-256
1fe4510c97b0f912ab95ef51a93baf094ddbd850bfda75e5f504d2b2dd8b4b8e
MD5
e3a5d76bfc9c02bdaba30bc75256376e

Download from the command line

curl -L -o .htaccess https://files.samplefiles.com/config/htaccess/.htaccess

Or check the download in your browser with the checksum calculator.