Access doar la anumite fisiere, cu htaccess

Probleme, intrebari si subiecte legate de Server Apache, setari in fisier htaccess si Gazduire site-uri Web (Hosting).
sterica
Mesaje: 285

Access doar la anumite fisiere, cu htaccess

ca sa nu fiu nevoit sa adaug in htaccess, fiecare fisier ce nu vreau sa fie accesat direct din browser, am posibilitatea sa le includ pe toate by default si sa adaug doar exceptiile?

Multumesc!

MarPlo Mesaje: 4343
Poti sa te folosesti de acest cod in htaccess:

Cod: Selectaţi tot

# set index.php as default index file
DirectoryIndex index.php 

#set to not show directory structure
Options -Indexes

#block access to all not allowed files
order allow,deny

#allow access to these php files
<files ~ '(index|file_2|file_3)\.php$'>
 allow from all
</files>

#allow access to these html files
<files ~ '(index|404|file_2|file_3)\.html$'>
 allow from all
</files>

#access for browser to the: bmp, css, gif, htm, ico, jpg, json, js, pdf, png, txt, xml files
<files ~ '(.*?)\.(bmp|css|gif|htm|ico|jpg|json|js|pdf|png|txt|xml)$'>
 allow from all
</files>

#allow access to address without file name after domain/
<files ''>
 allow from all
</files>