LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 07: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 05:24 PM. Reason: Remove some repititions
 
Old 06-21-2014, 03:00 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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, 09: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, 10:43 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

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

Regards
 
Old 06-21-2014, 11:54 AM   #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 05:24 PM. Reason: Remove some repititions
 
  


Reply



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 10:40 AM
deny a user access to specific command krock923 Linux - Security 7 10-11-2012 03:04 PM
Deny root access to a given file phru Linux - Security 6 12-08-2010 11:06 AM
How to deny root access to specific user's files haariseshu Red Hat 8 09-04-2009 07:36 AM
.htaccess AuthType Basic - allowing free access to specific file? ivanatora Linux - Software 0 11-21-2007 02:28 AM

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

All times are GMT -5. The time now is 01:27 PM.

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
Open Source Consulting | Domain Registration