开发者

VirtualHosts 404 for hidden files

开发者 https://www.devze.com 2023-03-06 07:45 出处:网络
I\'m using a friendly url solution that i achieve with the following lines in VirtualHosts RewriteEngine on

I'm using a friendly url solution that i achieve with the following lines in VirtualHosts

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteR开发者_Go百科ule ^(.*)$ script.php?$1

So i can have url's like http://example.com/something/something/else/other/things/

But how could i send a 404 status to the user who requests any url that has a folder starting with /. (it doesn't have to exist)

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

Examples that shouldn't be denied:

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

I've tried playing with FilesMatch and DirectoryMatch but this is more of a virtual path and i couldn't get it to work. Thank you for your help


If I understand the question, you are looking to throw a 404 error anytime some tries to access a hidden or directory? If so the following will do so, though I can't say it works against no existent files.

RewriteRule "(^|/)." - [R=404,L]

HTML5 Boilerpplate has a very nice and well documented .htaccess file, I would recommend checking that out. http://html5boilerplate.com/

0

精彩评论

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

关注公众号