Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically show a blank page in a folder without a default html page

Tags:

In my site I have many folders that holds different type of files.

/img/ /js/ /styles/ /files/ 

(I have 20 more and I will add more eventually)

Currently, I have in each folder a index.html (my default directory) that has a meta tag redirect to the web root level.

Is there a better method or an easier way to redirect dynamically these folders to the web root without creating a file everytime?

Edit: I am using: CentOS 5.7 + Apache 2 + php 5.3.5 + MySQL 5.1

Thank you

like image 680
Tech4Wilco Avatar asked Oct 06 '11 14:10

Tech4Wilco


1 Answers

I do not think there's a mod for what you need. Here's what I suggest:

RewriteEngine On RewriteBase /  RewriteRule ^(img|js|styles|files)/?$ http://www.domain.com/ [R=301,L] 

This way, if someone request http://www.domain.com/img/, he will automatically get redirected to the main page.

OR if you prefer:

RewriteRule ^(img|js)/?$ - [F] 

that will give a permission denied.

like image 188
Pat R Ellery Avatar answered Oct 13 '22 00:10

Pat R Ellery