cd /news/developer-tools/a-full-htaccess-file · home topics developer-tools article
[ARTICLE · art-9752] src=gist.github.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

A full .htaccess file

This article provides the full contents of an `.htaccess` file, a configuration file used by Apache web servers. The file includes commented-out directives for password protection and PHP code type masking, along with active settings for defining font MIME types, setting a staging environment variable, enabling gzip compression via mod_deflate, and setting browser caching expiration times via mod_expires.

read4 min views14 publishedMar 12, 2015

.htaccess

  This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.

Learn more about bidirectional Unicode characters

Show hidden characters

AddType application/vnd.ms-fontobject .eot

AddType application/x-font-opentype .otf

AddType image/svg+xml .svg

AddType application/x-font-ttf .ttf

AddType application/font-woff .woff

SetEnv PYRO_ENV staging

<IfModule mod_deflate.c>

<IfModule mod_setenvif.c>

<IfModule mod_headers.c>

    SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding

    RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding

</IfModule>

</IfModule>

<IfModule filter_module>

FilterDeclare COMPRESS

FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html

FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css

FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain

FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml

FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component

FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript

FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json

FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml

FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml

FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml

FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml

FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject

FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml

FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype

FilterChain COMPRESS

FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no

</IfModule>

<IfModule !mod_filter.c>

AddOutputFilterByType DEFLATE text/html text/plain text/css application/json

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE text/xml application/xml text/x-component

AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml

AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype

</IfModule>

</IfModule>

<IfModule mod_expires.c>

ExpiresActive on

ExpiresDefault "access plus 1 month"

ExpiresByType text/cache-manifest "access plus 0 seconds"

ExpiresByType text/html "access plus 0 seconds"

ExpiresByType text/xml "access plus 0 seconds"

ExpiresByType application/xml "access plus 0 seconds"

ExpiresByType application/json "access plus 0 seconds"

ExpiresByType application/rss+xml "access plus 1 hour"

ExpiresByType image/x-icon "access plus 1 week"

ExpiresByType image/gif "access plus 1 month"

ExpiresByType image/png "access plus 1 month"

ExpiresByType image/jpg "access plus 1 month"

ExpiresByType image/jpeg "access plus 1 month"

ExpiresByType video/ogg "access plus 1 month"

ExpiresByType audio/ogg "access plus 1 month"

ExpiresByType video/mp4 "access plus 1 month"

ExpiresByType video/webm "access plus 1 month"

ExpiresByType text/x-component "access plus 1 month"

ExpiresByType font/truetype "access plus 1 month"

ExpiresByType font/opentype "access plus 1 month"

ExpiresByType application/x-font-woff "access plus 1 month"

ExpiresByType image/svg+xml "access plus 1 month"

ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

ExpiresByType text/css "access plus 1 year"

ExpiresByType application/javascript "access plus 1 year"

ExpiresByType text/javascript "access plus 1 year"

<IfModule mod_headers.c>

Header append Cache-Control "public"

</IfModule>

</IfModule>

<IfModule mod_headers.c>

Header unset ETag

</IfModule>

FileETag None

<IfModule mod_rewrite.c>

Options +FollowSymLinks -Indexes

Options -MultiViews

RewriteEngine on

#RewriteCond %{HTTP_HOST} ^local.domain.com$

#RewriteRule (.*) $1 [E=PYRO_ENV:development] #RewriteCond %{HTTP_HOST} ^stage.domain.com$

 #RewriteRule (.*) $1 [E=PYRO_ENV:staging]

 #RewriteCond %{HTTP_HOST} ^domain.com$

 #RewriteRule (.*) $1 [E=PYRO_ENV:production]

#AllowOverride All

#RewriteBase /wherever/cms/is

 RewriteCond %{HTTPS} !=on

 RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]

 RewriteRule ^(.*)$ http://%1/$1 [R=301,L]


 #RewriteCond %{HTTPS} !=on

 #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]

 #RewriteCond %{HTTP_HOST} (.+)$ [NC]

 #RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

RedirectMatch 403 ^/./(system/cms/cache|system/codeigniter|system/cms/config|system/cms/logs|.git|.hg).$

 RewriteCond %{REQUEST_FILENAME} !-f

 RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_php5.c>

RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>

<IfModule !mod_php5.c>

RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>

</IfModule>

── more in #developer-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/a-full-htaccess-file] indexed:0 read:4min 2015-03-12 ·