Skip to content

Instantly share code, notes, and snippets.

@christianseel

christianseel/.htaccess

Last active Dec 27, 2015
Embed
What would you like to do?
MODX Revolution default .htaccess for All-Inkl.com
# ----------------------------------------------------------------------
# PHP Settings
# ----------------------------------------------------------------------
# php cgi 5.4.x
AddHandler php54-cgi .php
# set default timezone
php_value date.timezone "Europe/Berlin"
# Do not display errors in browser (production - Off, development - On)
php_flag display_errors on
# Do not display startup errors (production - Off, development - On)
php_flag display_startup_errors on
# set php error log
php_value error_log /www/htdocs/w01130a9/php_errors.log
# Write errors to log file
php_flag log_errors On
# prevent access to PHP error log
<Files php_errors.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
# magic_quotes_gpc off
php_flag magic_quotes_gpc Off
# register_globals off
php_flag register_globals Off
# ----------------------------------------------------------------------
# UTF-8 encoding
# ----------------------------------------------------------------------
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8
php_value default_charset utf-8
# Force UTF-8 for a number of file formats
AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml
# ----------------------------------------------------------------------
# Enable Rewrite Engine
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
Options +FollowSymlinks
Options -MultiViews
RewriteEngine On
RewriteBase /
</IfModule>
# ----------------------------------------------------------------------
# Domain Rewrite
# ----------------------------------------------------------------------
# Rewrite www.domain.com -> domain.com
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^name.kunden.chsmedien\.de [NC]
#RewriteRule (.*) https://name.kunden.chsmedien.de/$1 [R=301,L]
# Rewrite to force SSL (optional if available)
#RewriteCond %{SERVER_PORT} 80
#RewriteRule (.*) https://name.kunden.chsmedien.de/$1 [R=301,L]
# ----------------------------------------------------------------------
# More security
# ----------------------------------------------------------------------
# "-Indexes" will have Apache block users from browsing folders without a default document
# Usually you should leave this activated, because you shouldn't allow everybody to surf through
# every folder on your server (which includes rather private places like CMS system folders).
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
# Block access to "hidden" directories whose names begin with a period. This
# includes directories used by version control systems such as Subversion or Git.
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} -d
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>
# Block access to htaccess and htpasswd files
<FilesMatch "\.(htaccess|htpasswd)$">
order allow,deny
deny from all
</FilesMatch>
# Block access to backup and source files
# This files may be left by some text/html editors and
# pose a great security danger, when someone can access them
<FilesMatch "\.(bak|config|sql|fla|psd|ini|log|sh|inc|~|swp)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
# ----------------------------------------------------------------------
# Better IE experience
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=edge"
# `mod_headers` can't match based on the content-type, however, we only
# want to send this header for HTML pages and not for the other resources
<FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svgz?|ttf|vcf|webapp|webm|webp|woff|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>
# ----------------------------------------------------------------------
# Custom Rewrites
# ----------------------------------------------------------------------
#RewriteRule ^produkte/(.+)/$ produkte/?name=$1 [L,QSA]
# ----------------------------------------------------------------------
# MODX Friendly URLs part
# ----------------------------------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# ----------------------------------------------------------------------
# Compression
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
# Force compression for mangled headers.
# http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
<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>
# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
# as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/x-web-app-manifest+json \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment