TWB
v2014.05.26.09.09.57

HTML-File mit PHP

AddType application/x-httpd-php php php4 php3 html htm

HTML-File mit PHP

RewriteEngine on
RewriteRule ^(.*).html$ $1.php

Helpfull

Options +Indexes

AllowOverride All

AddDefaultCharset UTF-8

php_flag short_open_tag on

LOG php errors

php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag  log_errors on
php_value error_log /www/htdocs/w0012345/logs/phperrors.log

Rewrite

RewriteEngine On
RewriteBase /folder

www!

RewriteCond %{HTTP_HOST} !^www\.DOMAIN\.COM$
RewriteRule ^(.*)$ http://www.DOMAIN.COM/$1 [L,R=301]

oder nicht www!

RewriteCond %{HTTP_HOST} ^([^.]+)\.DOMAIN\.COM$ [NC]
RewriteRule ^(.*)$ http://DOMAIN.COM/$1 [L,R=301]

url-parameter einfach auf base leiten ( brutal )

RewriteCond %{QUERY_STRING} (^id=.*$)|(^gid=.*$)|(^tid=.*$)|(^lng=.*$)
RewriteRule .* \/? [R=301,L]

RedirectPermanent

RedirectPermanent /CONTENT.HTML    HTTP://DOMAIN.COM/NEW-CONTENT.HTML

Kompression

<IfModule mod_deflate.c>
    <FilesMatch "\.(js|jpg|jpeg|gif|png|css|txt|html)$">
        ExpiresActive on
        ExpiresDefault "access plus 1 month"
        SetOutputFilter DEFLATE
    </FilesMatch>
</IfModule>

<IfModule mod_gzip.c>
    mod_gzip_on       Yes
    mod_gzip_dechunk  Yes
    mod_gzip_item_include file      \.(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler   ^cgi-script$
    mod_gzip_item_include mime      ^text/.*
    mod_gzip_item_include mime      ^application/x-javascript.*
    mod_gzip_item_exclude mime      ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>

Expiration (for Caching)

<ifmodule mod_headers.c>
    <filesmatch "\\.(ico|jpe?g|png|gif|swf)$">
        Header set Cache-Control "max-age=2592000, public"
    </filesmatch>
    <filesmatch "\\.(css)$">
        Header set Cache-Control "max-age=604800, public"
    </filesmatch>
    <filesmatch "\\.(js)$">
        Header set Cache-Control "max-age=216000, private"
    </filesmatch>
    <filesmatch "\\.(x?html?|php)$">
        Header set Cache-Control "max-age=600, private, must-revalidate"
    </filesmatch>
</ifmodule>

REDIRECT Favicon

<Ifmodule mod_rewrite.c>
    RewriteCond %{THE_REQUEST} ^([^.]+)\favicon.ico [NC]
    RewriteRule ^(.*)$ http://example.com/favicon.ico [R=301,L]
</Ifmodule>

Add trailing slash

<Ifmodule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

PROTECT config.php

<files config.php>
    Order deny,allow
    deny from all
</files>

DISABLE HOTLINKING OF IMAGES WITH FORBIDDEN OR CUSTOM IMAGE OPTION

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/.*$ [NC]
    # RewriteRule \.(gif|jpg)$ - [F]
    RewriteRule \.(gif|jpg)$ http://www.example.com/stophotlinking.jpg [R,L]
</IfModule>

Regeln von IP-Bereichen

Order deny,allow
Allow from all
deny from 83.246.96.42
deny from 82.103.133.221
deny from 74.86.15.2
deny from 72.249.103.154