用户名:
密 码: 记住
您当前的位置:首页 > 站长百科 > 服务器技术

apache rewrite规则实现白名单

时间:2015-01-18  来源:互联网  作者:佚名

需求:

      六个文件的入口,其他都重定向到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>

来顶一下
返回首页
返回首页
推荐资讯
【图文教程】dede织梦网站后台如何发表文章? 【图文教程】dede织梦网站后台如何对于新手站长可能不了解,dede织梦后台是如何发文章的。下面
2014站长圈十大事件:PR已死 移动算法兴起 2014站长圈十大事件:PR已死 移动算2014年即将过去,虽然站长圈相比过去几年稍显沉寂,但&ldquo
相关文章
    无相关信息
栏目更新
栏目热门