I'm searchin on internet sin开发者_JAVA百科ce yesterday and i couldn't find the answer. At least one that works for apache2.
I just want a set of rewritemod rules that will make apache redirect everything to a 404 but allows me to explicitly override it for some files/folders.
I've tried an inclusive rule but i couldn't get it working.
Thanks.
Just try this line in your .htaccess file:
RewriteRule ^(?!(allowedFile\.html|allowedDirectory/)) - [R=404,L,NC]
Above rule will throw 404 for everything except a file called allowedFile.html
and a folder called allowedDirectory
.
RewriteRule ^/protectedfolder/(.*) - [L] /* no substitution , serve as it is for this folder*/
RewriteRule ^$ - [R=404,L] /*reject everything */
精彩评论