Hinweis! Nicht alle Einstellungen zeigen auf allen Apache Servern eine Wirkung. Die Konfiguration von ModRewrite z.B. muss vom Provider in der Apache-Config explizit erlaubt werden. Erlaubt der Provider einige der Einstellungen via .htaccess nicht, passiert im besten Fall gar nichts, im schlimmsten Fall gibt der Webserver einen Error 500 aus. In solch einem Fall löscht man ganz einfach die .htaccess Datei wieder und alles sollte wieder beim alten sein.

Mit Hilfe einer .htaccess Datei lässt sich nicht nur ein Passwortschutz realisieren, viele Apache Direktiven lassen sich zur Laufzeit beeinflussen. Der htaccesser bietet dafür eine Hilfestellung.

"; $output.="

order allow,deny

deny from all



"; $output.="

Redirect permanent / https://$force_ssl_domain/"; $output.="



Your .htaccess file contents

if (isset($_REQUEST['submit'])) { //export the form submits to global variables while (isset($_REQUEST)&&(list($k,$v)=each($_REQUEST))) { if ($v) { $$k=$v; } } $output=""; $options=""; $cgi_hand=""; if (isset($opt_execCGI)) { $options.=" +execCGI"; if (isset($handle_cgi)) { $cgi_hand.=" cgi"; } if (isset($handle_pl)) { $cgi_hand.=" pl"; } if (isset($handle_exe)) { $cgi_hand.=" exe"; } if (isset($handle_sh)) { $cgi_hand.=" sh"; } if (isset($cgi_hand)) { $output.="

AddHandler cgi-script $cgi_hand"; } }; if (isset($opt_include)) { $options.=" +Includes"; } else { if (isset($opt_includeNOEXEC)) { $options.=" +IncludeNOEXEC"; } } if (isset($opt_FollowSymLinks)) { $options.=" +FollowSymLinks"; } if (isset($opt_FollowSymLinksIfOwnerMatch)) { $options.=" +FollowSymLinksIfOwnerMatch"; } if (isset($opt_indexes)) { $options.=" +Indexes"; } if (isset($opt_multiview)) { $options.=" +MultiViews";} if (isset($auth_name)||isset($auth_user)||isset($auth_group)) { $output.="

AuthType Basic"; } if (isset($auth_name)) { $output.="

AuthName \"$auth_name\""; } if (isset($auth_user)) { $output.="

AuthUserFile $auth_userpath"; } if (isset($auth_group)) { $output.="

AuthGroupFile $auth_userpath"; } if (isset($auth_denyall)) { $output.="

Order allow,deny"; } else { $output.="

Order deny,allow"; } if (isset($satisfy_any)) { $output.="

Satisfy Any"; } if (isset($auth_valid_user)) { $output.="

Require valid-user"; } if (isset($auth_allow_users)) { $output.="

Require user $auth_allow_users"; } if (isset($auth_allow_groups)) { $output.="

Require group $auth_allow_groups"; } if (isset($auth_allow_ip)) { $output.="

Allow from $auth_allow_ip"; } if (isset($auth_deny_ip)) { $output.="

Deny from $auth_deny_ip"; } if (isset($mime_types)) { if (is_array($mime_types)) { while (list($k,$v)=each($mime_types)) { $output.="

AddType $v"; } } else { $output.="

AddType $mime_types"; } } if (isset($opt_includeNOEXEC)||isset($opt_include)) { if (isset($opt_include_ext)) { $output.="

AddType text/html $opt_include_ext

AddHandler server-parsed $opt_include_ext";}; }; if (isset($protect)) { $output.="

"; } if (isset($redirect)) { $output.="

Redirect permanent /$redirect_file $redirect_url"; } if (isset($force_ssl)) { $output.="

"; } if (isset($no_index)) { $output.="

IndexIgnore */*"; } if (isset($cache)) { $output.="

ExpiresActive on

ExpiresDefault "; if (isset($cache_server)) { $output.="M"; } else { $output.="A"; } $output.=$cachelength; } if (isset($check_media_referrer)) { $modrewrite="true"; } if (isset($failed_redirect)) { $modrewrite="true"; } if (isset($user_dir)) { $modrewrite="true"; } if (isset($timed_pages)) { $modrewrite="true"; } if (isset($block_harvesters)) { $modrewrite="true"; } if (isset($rewrite_browser_page)) { $modrewrite="true"; } if (isset($remap_script)&&isset($remap_folder)) { $modrewrite="true"; } if (isset($modrewrite)&&($modrewrite!="false")) { $output.="

RewriteEngine on"; if (isset($check_media_referrer)) { $output.="

".'RewriteCond %{HTTP_REFERER} !^$'; $output.="

".'RewriteCond %{HTTP_REFERER} !^http://(www\.)?'.$referrer_domain.'/.*$ [NC]'; $output.="

".'RewriteRule \.(gif|jpg|png|mp3|mpg|avi|mov)$ - [F] '; } if (isset($failed_redirect)) { $output.="

".'RewriteCond %{REQUEST_URI} !-U'; $output.="

".'RewriteRule ^(.+) http://'.$failed_redirect_server.'/$1'; } if (isset($user_dir)) { $user_domain=str_replace('.','\.',$user_domain); $output.="

".'RewriteCond %{HTTP_HOST} ^www\.[^.]+\.'.$user_domain.'$'; $output.="

".'RewriteRule ^(.+) %{HTTP_HOST}$1 [C]'; $output.="

".'RewriteRule ^www\.([^.]+)\.'.$user_domain.'(.*) /'.$user_dir_path.'$1$2'; } if (isset($timed_pages)) { $timed_page=str_replace('.','\.',$timed_page); $output.="

".'RewriteCond %{TIME_HOUR}%{TIME_MIN} >'.$timed_page_start; $output.="

".'RewriteCond %{TIME_HOUR}%{TIME_MIN}

Copy the lines below and paste them into your .htaccess file

Default Page What page to load if the user doesn't specify any (usually index.html or index.php)

Can specify multiple in a list (ie index.php index.html index.htm default.htm) Directory Index Options CGI execute CGI programs Execution of CGI scripts using mod_cgi is permitted. File Extensions .cgi .pl .exe .sh SSI include files (SSI) or without #exec

file extension Server-side includes provided by mod_include are permitted. Symbolic Links Follow Symbolic Links The server will follow symbolic links in this directory. Follow Symbolic Links if owner matches The server will only follow symbolic links for which the target file or directory is owned by the same user id as the link. Index Indexes If a URL which maps to a directory is requested, and there is no DirectoryIndex (e.g., index.html) in that directory, then mod_autoindex will return a formatted listing of the directory. MultiViews Content Negotiation (MultiViews) Content negotiated "MultiViews" are allowed using mod_negotiation. SSL Force SSL SSL Domain Force HTTP requests to redirect HTTPS Authentication Deny by default

Require valid username

All if user OR ip matches

Area Name

User Authentication path to users file

Group Authentication path to groups file

Allowed Users

Allowed Groups

Allowed IP addresses (wildcards and names allowed)

Blocked IP addresses (wildcards and names allowed)

Additional Mime Types $fp=fopen("./mime.types","r"); if ($fp) { while (!feof($fp)) { $line=trim(fgets($fp,4096)); $ext=strstr($line," "); echo " $ext "; } fclose($fp); } ?> File extension to mime type mappings are in this format

mime/type ext

for example

text/html html

application/x-gzip gz Protect System Files Protect .htaccess and user and group files

Additional files to protect File Cache Control Specify File Cache Time How often will the client/proxy refresh the file Modification Based Expire all clients/proxies at the same time Cache Time 1 Year 6 Months 3 Months 1 Month 1 Week 1 Day 1 Hour 1 Minutes ModRewrite Protect Media Files On:

Allowed Domain: Check the referrer domain for images, music, and sound files Block E-mail Harvesters On:

Page to server: Deny access to e-mail harvesting programs. Time-Dependant Page On:

Page Name:

Daytime Starts:

Daytime Ends:

Daytime Page:

Nighttime Page: Serve pages depending on time of day Virtual DNS to Folder On:

Base Domain: Path to Folders: Rewrite Virtual Subdomains to subfolders. Ie: rewrite www.foo.domain.com to www.domain.com/subdomains/foo. Useful for virtual user domains. Redirect Failing URLs To Other Webserver On:

Secondary Server: When a URL is invalid, or would produce an error, redirect to a secondary server. Rewrite Condition Rewrite Page Page Name: Page requested in the URL Browser Dependant Page Netscape Page Page to use for Netscape

IE Page Page to use for IE

Page for Lynx Page to use for text mode

Default Page Page to use for other browsers Country Specific Page Requires the mod_geoip is setup and configured on your server. Thought the software is free, the datafiles are a commercial product. Allows you to redirect users to specific pages depending on their country of origin. Country Code US = United States GB = United Kingdom CA = Canada MX = Mexico FR = France NL = Netherlands A1 = Anonymous Country Specific URL page to redirect visitors from the country (index.us.html or index.fr.html) Map Folder To Script This trick will make it possible to run a script that has parameters in the URL. You can make a custom home page script for your users that they can access like /login/home.html or /login/preferences.html and have them both go to login.php. Folder Name Folder you will reference in your href and urls (ie login) Script Name Script that will be ran (ie login.php, login.cgi, or login.pl) If you would like the rest of the path as a POST variable, do something like "login.php?page=" Custom Error Documents Allows you to specify custom documents to serve on error conditions Error 400 Bad Request

Error 401 Authentication Required

Error 403 Forbidden

Error 404 Not Found

Error 500 Server Error Bad RequestAuthentication RequiredForbiddenNot FoundServer Error Redirection Use this option if a document has been moved to a new url. It will take care of automatic redirection for the user. Redirect Moved Document

Moved Document

New URL



};?>