php - .htaccess deny from all, redirect to 404 page and except for 2 files -


how setup .htaccess denys .php file access in include/ folder, , redirect user error page in public_html/ (root) directory when 403, 404 , 500 occurs, except 2 files called index.php , key.php?

currently have:

<files "^*\.php$"> order allow,deny deny </files> errordocument 403 /error.html errordocument 404 /error.html errordocument 500 /error.html  <filesmatch "^(index|key)\.php$"> allow </filesmatch> 

but not work properly, <filesmatch "^(index|key)\.php$"> works fine.

thanks!

you should place .htaccess file include/ directory, if it's not case. think used filesmatch syntax files tag.

<filesmatch "^.*\.php$>     order deny,allow # deny here, allow later.     deny </files>  <filesmatch "^(index|key)\.php$">     allow  # allow here. </files> 

then, in root (public_html/), can use :

errordocument 403 /error.html # try ../error.html if put line in include/.htaccess 

make sure path error.html valid. if see "an error encountered looking error document", it's wrong (try absolute path linux root ?)


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -