LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-20-2014, 08:52 PM   #1
Dareros
LQ Newbie
 
Registered: May 2014
Posts: 13

Rep: Reputation: Disabled
How to deny access to specific file using htaccess ?


Hi;
I would like to deny access to .log files but with an additional condition, if the requested filename of the log file exist than deny access but if the requested filename doesn't exist than do nothing. Example, i have in my web server a file called web.log so the request should be denied but the request shouldn't be denied because the file webo.log doesn't exist. So i need to check first if the file exist, if yes deny if no do nothing. The traditional command which doesn't check if the requested file exist or no, so i need to add conditions so how to do that with htaccess ?

Thank you.

Last edited by Dareros; 06-21-2014 at 06:24 PM. Reason: Remove some repititions
 
Old 06-21-2014, 04:00 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,004

Rep: Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624
Hi,

Use mod_rewrite:
Code:
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} (.*).log
RewriteRule (.*) - [F]
Cheers
 
1 members found this post helpful.
Old 06-21-2014, 10:27 AM   #3
Dareros
LQ Newbie
 
Registered: May 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Thank you very much bathory.
 
Old 06-21-2014, 11:43 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,004

Rep: Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624
You're welcome.
You may mark the thread as "SOLVED" from the "Thread Tools" on top of the page

Regards
 
Old 06-21-2014, 12:54 PM   #5
Dareros
LQ Newbie
 
Registered: May 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Okay, i got how to do it. Thanks again.

Last edited by Dareros; 06-21-2014 at 06:24 PM. Reason: Remove some repititions
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to select a specific file with a path using .htaccess Dareros Linux - Software 3 06-14-2014 11:40 AM
deny a user access to specific command krock923 Linux - Security 7 10-11-2012 04:04 PM
Deny root access to a given file phru Linux - Security 6 12-08-2010 12:06 PM
How to deny root access to specific user's files haariseshu Red Hat 8 09-04-2009 08:36 AM
.htaccess AuthType Basic - allowing free access to specific file? ivanatora Linux - Software 0 11-21-2007 03:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration