Skip to content

Commit

Permalink
Merge pull request #25 from inpsyde/issue/23_htaccess
Browse files Browse the repository at this point in the history
Improve generated .htaccess file. #23
  • Loading branch information
tfrommen authored Jul 28, 2017
2 parents 88b0035 + 19f1f5e commit 41a02f0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Handler/DefaultHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,20 @@ private function maybe_create_htaccess( $folder ) {

$handle = fopen( "{$folder}/.htaccess", 'w' );

if ( $handle && flock( $handle, LOCK_EX ) && fwrite( $handle, "Deny from all\n" ) ) {
flock( $handle, LOCK_UN );
chmod( "{$folder}/.htaccess", 0444 );
if ( $handle && flock( $handle, LOCK_EX ) ) {
$htaccess = <<<'HTACCESS'
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
HTACCESS;

if ( fwrite( $handle, $htaccess ) ) {
flock( $handle, LOCK_UN );
chmod( "{$folder}/.htaccess", 0444 );
}
}

fclose( $handle );
Expand Down

0 comments on commit 41a02f0

Please sign in to comment.