Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've set a virtual directory in /etc/apache2/sites-available/default like so:

    Alias /lynx/ "/home/srv1100/"
    <Directory "/home/srv1100/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>

every file is accessible when I write http://127.0.0.1/lynx/... I want that only files, which their extension is NOT "bsp" or "nav" and will be accessible. I can't put them in other directory.

Any ideas?

Thanks.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You can use Apache's mod_rewrite to do this.

RewriteEngine On
RewriteRule \.(bsp|nav)$ - [nocase,gone,last]
share|improve this answer
    
This is a GREAT idea, Thanks! –  Alon Gubkin Feb 2 '10 at 16:55
    
Ahh, mod_rewrite...is there anything you can't do? –  baumgart Feb 2 '10 at 17:40
add comment

Please see the mod_autoindex documentation at http://httpd.apache.org/docs/2.0/mod/mod_autoindex.html

Check out the IndexIgnore directive.

share|improve this answer
    
This prevents the files from showing up in the autoindex, but does not prevent a user from typing in the filename on the URL line and downloading them. You can accomplish the latter via file permissions (or creative use of mod_rewrite). –  voretaq7 Feb 2 '10 at 16:46
    
Yeah, I missed that :(. Use file permissions to do it quickly, mod_rewrite to do it correctly. Just as an aside, you may want to look at your architecture/design a little bit regarding these files. If you don't want people downloading them, then why are they in a webroot? If you're including them in pages then permissions are going to break your site and you'll have to use mod_rewrite. If they're not included in your content, then why are they there? Just some food for thought. –  d34dh0r53 Feb 2 '10 at 16:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.