服务器 
首页 > 服务器 > 浏览文章

apache rewrite规则实现白名单

(编辑:jimmy 日期: 2024/9/20 浏览:3 次 )

需求:

      六个文件的入口,其他都重定向到index

自己的思路:

      正则找出不是六个文件的URL的模式,进行过滤。

对比同事的结果,自己思路的问题:

      1. 想找出所有不符合规则的,越想越多,无法下手。----------------   思路错误,应该 制定白名单,

      2. 概念错误, 弄错 REQUEST_URI 和 REQUEST_STRING 的概念   基础知识不牢固。

最后结果:
复制代码 代码如下:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^/(.*) /index.asp$1 [L]
RewriteCond %{REQUEST_URI} ^/index.asp [NC,OR]
RewriteCond %{REQUEST_URI} ^/o.asp [NC,OR]
RewriteCond %{REQUEST_URI} ^/s.asp [NC,OR]
RewriteCond %{REQUEST_URI} ^/error.asp [NC,OR]
RewriteCond %{REQUEST_URI} ^/favicon.ico [NC,OR]
RewriteCond %{REQUEST_URI} ^/status.taobao [NC,OR]
RewriteCond %{REQUEST_URI} ^/app/thirdparty/webbox.asp [NC,OR]
RewriteCond %{REQUEST_URI} ^/static/ [NC]
RewriteRule ^.* - [L]
RewriteCond %{REQUEST_URI} !^/index.asp$
RewriteRule ^.* – [F,L]
</IfModule>

上一篇:在网关中使用Nginx配置HTTP透明代理案例
下一篇:Nginx对某个目录设置密码保护例子
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap