开发者

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

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 ever开发者_如何学Cytime?

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

Thank you


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜