0

I am trying to redirect all files except those in whitelist to 404 page.. but I can't find a way to add something like RewriteCond to my current htaccess code:

RedirectMatch 404 ^.*$

Now i want to add something like

RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|js|png)$

though i know RewriteCond is only for RewriteRule

can someone please help me?

So the question is, how can I achieve this?

thanks!

4

1 回答 1

1

在 RedirectMatch 语句中使用正则表达式应该适合您:

RedirectMatch 404 ^.*\.(?!(js|html|gif)).*$

后面括号里面的东西?!是您的白名单。此处未命名的每个文件扩展名都将导致 404。

于 2013-05-28T15:55:16.427 回答