Skip to content

Instantly share code, notes, and snippets.

@joachimdoerr
Created March 22, 2013 13:41
Show Gist options
  • Save joachimdoerr/5221357 to your computer and use it in GitHub Desktop.
Save joachimdoerr/5221357 to your computer and use it in GitHub Desktop.
Sinnvolle Alltags-".htaccess" Befehle
# auf domain auf www.domain umleiten
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
# www entfernen
RewriteEngine On
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]
# magic_quotes aktivieren
php_flag magic_quotes_gpc on
php_value register_globals 0
# php memory hochsetzen
php_value memory_limit 64M
# fix für IO Error Meldung wenn der Server die Verbindung vorzeitig beendet
# SecFilterEngine Off
# SecFilterScanPOST Off
# und multifileuploader http error fix
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
# einfache weiterleitung
RewriteRule podcast/rss.xml$ index.php?article_id=76&clang=0
# simuliert ordner "download" schleifen dateien über index.php?downloads
RewriteRule ^downloades/(.*) /index.php?downloadfile=$1&%{QUERY_STRING}
# url weiterleiten auf andere
RewriteCond %{HTTP_HOST} mydomain1.com$
RewriteRule ^/?$ http://www.mydomain2.com/domain1.html [R,L]
# startdatei festlegen
DirectoryIndex index.php
# default utf8
AddDefaultCharset utf-8
# custom error sites
ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html
# fancy indexing
IndexOptions FancyIndexing
IndexOptions FoldersFirst
IndexOptions NameWidth=*
# download file not open in browser
AddType application/octet-stream .csv
AddType application/octet-stream .xls
AddType application/octet-stream .doc
AddType application/octet-stream .avi
AddType application/octet-stream .mpg
AddType application/octet-stream .mov
AddType application/octet-stream .pdf
# ipad detection
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.mydomain.com [R=301]
# iphone dedection
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} .*iPhone.*
RewriteRule ^index\.html$ http://www.mobile.mydomain.com [L]
RewriteRule ^/$ http://www.mydomain.com/index.html [L]
</IfModule>
# php error logging
# display no errs to user
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
# log to file
php_flag log_errors on
php_value error_log /location/to/php_error.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment