2012-02-20 23 views
0

我想拒絕所有的東西;除下列情況應被允許:重寫規則:拒絕除root,文件和特定文件夾中的所有文件都

1 http://example.com/ 
2 http://example.com/favicon.ico 
3 http://example.com/downloads/secret/test.txt 

通過

RewriteEngine On 
RewriteRule !^(favicon\.ico|downloads/secret/[^/]+\.[a-z]+)?$ - [F,L] 

號碼2和3的工作就好了。但我不能達到http://example.com/

如何modifiy我重寫規則,使第一個例子中的工作呢?

+0

那些3應該還是不應該被允許? – ThinkingMonkey 2012-02-20 20:23:12

+0

應該被允許,遺憾的混亂。 – fanti 2012-02-20 20:28:27

回答

2

補充一點:什麼都索引文件使用的是

RewriteEngine on 
RewriteCond %{REQUEST_URI} !^/(?:|favicon\.ico|downloads/secret/test\.txt|index.php)$ 
RewriteRule^- [F] 

變化index.php到(如index.htmlindex.pl等)

+0

看起來不錯,但仍然http://example.com/不工作難道這是XAMPP的限制? – fanti 2012-02-20 20:46:09

+0

@fanti檢查更新。此外,改變'index.php'您正在使用什麼都索引文件(如index.html的,index.pl等)。 – ThinkingMonkey 2012-02-20 20:53:32

相關問題