Vous pouvez aussi utiliser un script php pour généré le .htaccess / .htpassword qui va bien la ou vous voulez.
Assurez-vous qu'il n'existe aucun .htaccess auparavant.
<?php //mes paramètres $Path = 'admin/'; //mon repertoire a proteger $Login = 'monlogin'; //Le login desire $Password = 'monpass'; //Le pass desire $Name = 'Zone protégé';//Le nom de la zone protege //creation du .htpasswd $fp = fopen($Path.'.htpasswd','w+'); if(!$fp) die('impossible de creer le fichier .htpasswd dans '.$Path); fputs($fp,$Login.':'.crypt($Password)); fclose($fp); //creation du .htaccess $fp = fopen($Path.'.htaccess','w+'); if(!$fp) die('impossible de creer le fichier .htaccess dans '.$Path); $out = 'AuthUserFile '; $out .= getcwd().$Path .".htpasswd\n"; //ici pb avec chemin windows $out .= 'AuthName "'.$Name.'"'."\n"; $out .= 'AuthType Basic'."\n\n"; $out .= '<limit GET POST>'."\n"; $out .= 'require valid-user'."\n"; $out .= '</limit>'; fputs($fp,$out); fclose($fp); echo "Opération OK"; ?>
Ce script ne fonctionne pas sous windows (problème de chemin)
|