LinuxQuestions.org
Review your favorite Linux distribution.
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-13-2014, 06:34 PM   #1
Dareros
LQ Newbie
 
Registered: May 2014
Posts: 13

Rep: Reputation: Disabled
How to select a specific file with a path using .htaccess


Hi;
I want to select a specific file by its path using .htaccess to allow access to it. I have tried both directives Files and FilesMatch none of them work for me. Here is what i have tried.

Code:
<Files "/var/www/site/system.log">
    Order Allow,Deny
    Allow from all
</Files>

<FilesMatch "/var/www/site/system.log">
    Order Allow,Deny
    Allow from all  
</FilesMatch>
What is the correct syntax ? Thank you.
 
Old 06-14-2014, 03:06 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,189
Blog Entries: 1

Rep: Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050
Hi,

The "Files" directive is used with just the filename, not with the whole path to the filename. So you can use:
Quote:
<Files "system.log">
Order Allow,Deny
Allow from all
</Files>
If you want to limit "Files" to a specific filename in a specific path, you can use:
Code:
<Directory /var/web/site>
<Files "system.log">
Order allow,deny
Allow from all
</Files>
</Directory>
Regards
 
1 members found this post helpful.
Old 06-14-2014, 09:18 AM   #3
Dareros
LQ Newbie
 
Registered: May 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Thank you for your reply, i added your code to my .htaccess file and give me the error 500 Internal server Error. I need to add the code to .htaccess not httpd.conf because i am using a shared hosting. So what is wrong ?

Last edited by Dareros; 06-14-2014 at 09:29 AM.
 
Old 06-14-2014, 10:40 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,189
Blog Entries: 1

Rep: Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050
Quote:
Originally Posted by Dareros View Post
Thank you for your reply, i added your code to my .htaccess file and give me the error 500 Internal server Error. I need to add the code to .htaccess not httpd.conf because i am using a shared hosting. So what is wrong ?
You cannot use a "<Directory ...> </Directory>" definition inside a .htaccess. That's why you get the 500 error.
But you can use the 1st alternative in my previous post.

Regards
 
2 members found this post helpful.
  


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 get file path for specific type of file on my server? Ferodactyl Linux - Newbie 5 08-08-2013 08:21 AM
[SOLVED] how to select date and some specific data from a log file shwhooda Linux - Newbie 2 06-25-2012 06:56 PM
.htaccess redirection to a specific directory sycamorex Linux - Server 2 02-02-2012 11:47 AM
.htaccess AuthType Basic - allowing free access to specific file? ivanatora Linux - Software 0 11-21-2007 02:28 AM
select the longest string of each unique path in a sorted text file powah Programming 5 03-01-2007 11:16 AM

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

All times are GMT -5. The time now is 01:09 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