How to avoid apache allow download certain files?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












How to avoid apache allow download certain files? (for example .py and .sh)



I want to avoid files to be served and downloaded like



www.site.com/file.sh
www.site.com/file.py


but I've tried to do this



<Files ~ "^.sh">
Order deny,allow
deny from all
</Files>

<Files ~ "^.py">
Order deny,allow
deny from all
</Files>


also this



<FilesMatch ".(sh|py)$">
Order deny,allow
deny from all
</FilesMatch>


Nothings seems to work, I've tried to put the file in




/etc/apache2/apache2.conf




also




/etc/apache2/sites-available/default




Nothing works, apache still let me download the files.










share|improve this question























  • Of course, this just means someone will simply rename the files with a .txt extension.
    – Andrew Henle
    Aug 15 at 15:27














up vote
2
down vote

favorite
1












How to avoid apache allow download certain files? (for example .py and .sh)



I want to avoid files to be served and downloaded like



www.site.com/file.sh
www.site.com/file.py


but I've tried to do this



<Files ~ "^.sh">
Order deny,allow
deny from all
</Files>

<Files ~ "^.py">
Order deny,allow
deny from all
</Files>


also this



<FilesMatch ".(sh|py)$">
Order deny,allow
deny from all
</FilesMatch>


Nothings seems to work, I've tried to put the file in




/etc/apache2/apache2.conf




also




/etc/apache2/sites-available/default




Nothing works, apache still let me download the files.










share|improve this question























  • Of course, this just means someone will simply rename the files with a .txt extension.
    – Andrew Henle
    Aug 15 at 15:27












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





How to avoid apache allow download certain files? (for example .py and .sh)



I want to avoid files to be served and downloaded like



www.site.com/file.sh
www.site.com/file.py


but I've tried to do this



<Files ~ "^.sh">
Order deny,allow
deny from all
</Files>

<Files ~ "^.py">
Order deny,allow
deny from all
</Files>


also this



<FilesMatch ".(sh|py)$">
Order deny,allow
deny from all
</FilesMatch>


Nothings seems to work, I've tried to put the file in




/etc/apache2/apache2.conf




also




/etc/apache2/sites-available/default




Nothing works, apache still let me download the files.










share|improve this question















How to avoid apache allow download certain files? (for example .py and .sh)



I want to avoid files to be served and downloaded like



www.site.com/file.sh
www.site.com/file.py


but I've tried to do this



<Files ~ "^.sh">
Order deny,allow
deny from all
</Files>

<Files ~ "^.py">
Order deny,allow
deny from all
</Files>


also this



<FilesMatch ".(sh|py)$">
Order deny,allow
deny from all
</FilesMatch>


Nothings seems to work, I've tried to put the file in




/etc/apache2/apache2.conf




also




/etc/apache2/sites-available/default




Nothing works, apache still let me download the files.







permissions security apache-httpd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 22 at 14:42

























asked Aug 8 at 17:48









Hernán Eche

666




666











  • Of course, this just means someone will simply rename the files with a .txt extension.
    – Andrew Henle
    Aug 15 at 15:27
















  • Of course, this just means someone will simply rename the files with a .txt extension.
    – Andrew Henle
    Aug 15 at 15:27















Of course, this just means someone will simply rename the files with a .txt extension.
– Andrew Henle
Aug 15 at 15:27




Of course, this just means someone will simply rename the files with a .txt extension.
– Andrew Henle
Aug 15 at 15:27










1 Answer
1






active

oldest

votes

















up vote
5
down vote



accepted
+50










Your file match clauses seem to be incorrect.



<Files ~ "^.py">


will match files whose names will start with characters .py. You'll want



<Files ~ ".py$">


instead.



But your FilesMatch regular expression looks correct. So maybe the problem lies elsewhere. Perhaps your Apache uses the new-style access control directives only?



Try replacing the old-style



Order deny,allow
deny from all


with the new-style equivalent:



Require all denied





share|improve this answer




















  • Done!, the <Files> fix, fixed the issue, in /etc/apache2/apache2.conf
    – Hernán Eche
    Aug 15 at 20:13










  • FilesMatch doesn't seem to work in this apache v 2.2
    – Hernán Eche
    Aug 15 at 20:16










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461330%2fhow-to-avoid-apache-allow-download-certain-files%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
5
down vote



accepted
+50










Your file match clauses seem to be incorrect.



<Files ~ "^.py">


will match files whose names will start with characters .py. You'll want



<Files ~ ".py$">


instead.



But your FilesMatch regular expression looks correct. So maybe the problem lies elsewhere. Perhaps your Apache uses the new-style access control directives only?



Try replacing the old-style



Order deny,allow
deny from all


with the new-style equivalent:



Require all denied





share|improve this answer




















  • Done!, the <Files> fix, fixed the issue, in /etc/apache2/apache2.conf
    – Hernán Eche
    Aug 15 at 20:13










  • FilesMatch doesn't seem to work in this apache v 2.2
    – Hernán Eche
    Aug 15 at 20:16














up vote
5
down vote



accepted
+50










Your file match clauses seem to be incorrect.



<Files ~ "^.py">


will match files whose names will start with characters .py. You'll want



<Files ~ ".py$">


instead.



But your FilesMatch regular expression looks correct. So maybe the problem lies elsewhere. Perhaps your Apache uses the new-style access control directives only?



Try replacing the old-style



Order deny,allow
deny from all


with the new-style equivalent:



Require all denied





share|improve this answer




















  • Done!, the <Files> fix, fixed the issue, in /etc/apache2/apache2.conf
    – Hernán Eche
    Aug 15 at 20:13










  • FilesMatch doesn't seem to work in this apache v 2.2
    – Hernán Eche
    Aug 15 at 20:16












up vote
5
down vote



accepted
+50







up vote
5
down vote



accepted
+50




+50




Your file match clauses seem to be incorrect.



<Files ~ "^.py">


will match files whose names will start with characters .py. You'll want



<Files ~ ".py$">


instead.



But your FilesMatch regular expression looks correct. So maybe the problem lies elsewhere. Perhaps your Apache uses the new-style access control directives only?



Try replacing the old-style



Order deny,allow
deny from all


with the new-style equivalent:



Require all denied





share|improve this answer












Your file match clauses seem to be incorrect.



<Files ~ "^.py">


will match files whose names will start with characters .py. You'll want



<Files ~ ".py$">


instead.



But your FilesMatch regular expression looks correct. So maybe the problem lies elsewhere. Perhaps your Apache uses the new-style access control directives only?



Try replacing the old-style



Order deny,allow
deny from all


with the new-style equivalent:



Require all denied






share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 15 at 18:46









telcoM

11.4k11333




11.4k11333











  • Done!, the <Files> fix, fixed the issue, in /etc/apache2/apache2.conf
    – Hernán Eche
    Aug 15 at 20:13










  • FilesMatch doesn't seem to work in this apache v 2.2
    – Hernán Eche
    Aug 15 at 20:16
















  • Done!, the <Files> fix, fixed the issue, in /etc/apache2/apache2.conf
    – Hernán Eche
    Aug 15 at 20:13










  • FilesMatch doesn't seem to work in this apache v 2.2
    – Hernán Eche
    Aug 15 at 20:16















Done!, the <Files> fix, fixed the issue, in /etc/apache2/apache2.conf
– Hernán Eche
Aug 15 at 20:13




Done!, the <Files> fix, fixed the issue, in /etc/apache2/apache2.conf
– Hernán Eche
Aug 15 at 20:13












FilesMatch doesn't seem to work in this apache v 2.2
– Hernán Eche
Aug 15 at 20:16




FilesMatch doesn't seem to work in this apache v 2.2
– Hernán Eche
Aug 15 at 20:16

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461330%2fhow-to-avoid-apache-allow-download-certain-files%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?