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.
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.
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.="\nAddHandler 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.="\nAuthType Basic"; }
if (isset($auth_name))
{ $output.="\nAuthName \"$auth_name\""; }
if (isset($auth_user))
{ $output.="\nAuthUserFile $auth_userpath"; }
if (isset($auth_group))
{ $output.="\nAuthGroupFile $auth_userpath"; }
if (isset($auth_denyall))
{ $output.="\nOrder allow,deny"; }
else
{ $output.="\nOrder deny,allow"; }
if (isset($satisfy_any))
{ $output.="\nSatisfy Any"; }
if (isset($auth_valid_user))
{ $output.="\nRequire valid-user"; }
if (isset($auth_allow_users))
{ $output.="\nRequire user $auth_allow_users"; }
if (isset($auth_allow_groups))
{ $output.="\nRequire group $auth_allow_groups"; }
if (isset($auth_allow_ip))
{ $output.="\nAllow from $auth_allow_ip"; }
if (isset($auth_deny_ip))
{ $output.="\nDeny from $auth_deny_ip"; }
if (isset($mime_types))
{
if (is_array($mime_types))
{
while (list($k,$v)=each($mime_types))
{
$output.="\nAddType $v";
}
} else
{
$output.="\nAddType $mime_types";
}
}
if (isset($opt_includeNOEXEC)||isset($opt_include))
{
if (isset($opt_include_ext))
{ $output.="\nAddType text/html $opt_include_ext\nAddHandler server-parsed $opt_include_ext";};
};
if (isset($protect)) {
$output.="\n
";
$output.="\norder allow,deny\ndeny from all\n";
}
if (isset($redirect)) {
$output.="\nRedirect permanent /$redirect_file $redirect_url";
}
if (isset($force_ssl))
{
$output.="\n
";
$output.="\nRedirect permanent / https://$force_ssl_domain/";
$output.="\n";
}
if (isset($no_index)) {
$output.="\nIndexIgnore */*";
}
if (isset($cache))
{
$output.="\nExpiresActive on\nExpiresDefault ";
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.="\nRewriteEngine on";
if (isset($check_media_referrer)) {
$output.="\n".'RewriteCond %{HTTP_REFERER} !^$';
$output.="\n".'RewriteCond %{HTTP_REFERER} !^http://(www\.)?'.$referrer_domain.'/.*$ [NC]';
$output.="\n".'RewriteRule \.(gif|jpg|png|mp3|mpg|avi|mov)$ - [F] ';
}
if (isset($failed_redirect))
{
$output.="\n".'RewriteCond %{REQUEST_URI} !-U';
$output.="\n".'RewriteRule ^(.+) http://'.$failed_redirect_server.'/$1';
}
if (isset($user_dir)) {
$user_domain=str_replace('.','\.',$user_domain);
$output.="\n".'RewriteCond %{HTTP_HOST} ^www\.[^.]+\.'.$user_domain.'$';
$output.="\n".'RewriteRule ^(.+) %{HTTP_HOST}$1 [C]';
$output.="\n".'RewriteRule ^www\.([^.]+)\.'.$user_domain.'(.*) /'.$user_dir_path.'$1$2';
}
if (isset($timed_pages))
{
$timed_page=str_replace('.','\.',$timed_page);
$output.="\n".'RewriteCond %{TIME_HOUR}%{TIME_MIN} >'.$timed_page_start;
$output.="\n".'RewriteCond %{TIME_HOUR}%{TIME_MIN} <'.$timed_page_end;
$output.="\n".'RewriteRule ^'.$timed_page.'$ '.$timed_page_day;
$output.="\n".'RewriteRule ^'.$timed_page.'$ '.$timed_page_night;
}
if (isset($block_harvesters)) {
$output.="\nRewriteCond %{HTTP_USER_AGENT} Wget [OR] ";
$output.="\nRewriteCond %{HTTP_USER_AGENT} CherryPickerSE [OR] ";
$output.="\nRewriteCond %{HTTP_USER_AGENT} CherryPickerElite [OR] ";
$output.="\nRewriteCond %{HTTP_USER_AGENT} EmailCollector [OR] ";
$output.="\nRewriteCond %{HTTP_USER_AGENT} EmailSiphon [OR] ";
$output.="\nRewriteCond %{HTTP_USER_AGENT} EmailWolf [OR] ";
$output.="\nRewriteCond %{HTTP_USER_AGENT} ExtractorPro ";
$output.="\nRewriteRule ^.*$ $block_doc [L]";
}
if (isset($rewrite_browser_page))
{ //rewrite browser pages
$rw_page='^'.str_replace('.','\.',$rewrite_browser_page).'$';
if (isset($geoip_country))
{
$output.="\nRewriteCond %{ENV:GEOIP_COUNTRY_CODE} $geoip_country [NC]";
$output.="\nRewriteRule $rw_page $geoip_page [L]\n";
}
if (isset($rewrite_browser_page_ns))
{
$output.="\n".'RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[345].*Gecko*';
$output.="\nRewriteRule $rw_page $rewrite_browser_page_ns [L]\n";
}
if (isset($rewrite_browser_page_ie))
{
$output.="\n".'RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[345].*MSIE*';
$output.="\nRewriteRule $rw_page $rewrite_browser_page_ie [L]\n";
}
if (isset($rewrite_browser_page_lynx))
{
$output.="\n".'RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[12].* [OR]';
$output.="\n".'RewriteCond %{HTTP_USER_AGENT} ^Lynx/*';
$output.="\nRewriteRule $rw_page $rewrite_browser_page_lynx [L]\n";
}
if (isset($rewrite_browser_page_default))
{
$output.="\nRewriteRule $rw_page $rewrite_browser_page_default [L]\n";
}
}
if (isset($remap_script)&&isset($remap_folder))
{
$output.="\nRewriteRule $remap_folder(.*) /$remap_script$1 [PT]";
}
}
if (isset($error_400)) { $output.="\nErrorDocument 400 $error_400"; }
if (isset($error_401)) { $output.="\nErrorDocument 401 $error_401"; }
if (isset($error_403)) { $output.="\nErrorDocument 403 $error_403"; }
if (isset($error_404)) { $output.="\nErrorDocument 404 $error_404"; }
if (isset($error_500)) { $output.="\nErrorDocument 500 $error_500"; }
if (isset($default_page)) { $output.="\nDirectoryIndex $default_page"; }
if ($options) { $output="Options $options\n".$output; }
?>
Your .htaccess file contents
Copy the lines below and paste them into your .htaccess file
};?>