2011-05-17 43 views
1

我使用,我在VirtualHosts以下行實現友好的URL的解決方案VirtualHosts 404隱藏文件

RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ script.php?$1 

所以我可以有網址的喜歡http://example.com/something/something/else/other/things/

但我怎麼能發送404狀態給請求具有以/開頭的文件夾的任何url的用戶。 (它沒有存在)不應該被剝奪

Example: http://example.com/.svn/this/should/be/404 
Example: http://example.com/other/things/.cannot/access/here 
Example: http://example.com/this/should/be/.denied 

例子:

Example: http://example.com/t.his/is/ok 

我試着FilesMatch和DirectoryMatch打不過這更是一個虛擬路徑和我的無法讓它工作。感謝您的幫助

回答

1

如果我明白了這個問題,您打算在任何時候嘗試訪問隱藏或目錄時拋出404錯誤?如果是這樣,以下將這樣做,但我不能說它對任何存在的文件都不起作用。

RewriteRule「(^ | /)」。 - [R = 404,L]

HTML5 Boilerpplate有一個很好的和有據可查的.htaccess文件,我建議檢查一下。 http://html5boilerplate.com/