防止搜索引擎的 user_agent 报错

回复 收藏

92         RewriteEngine on
93         RewriteCond %{HTTP_USER_AGENT}  ^.*Firefox/4.0* [NC,OR]
94         RewriteCond %{HTTP_USER_AGENT}  ^.*Tomato Bot/1.0* [NC]
95         RewriteRule  .*  -  [F]
96     

[root@pekut /]# /usr/local/apache2/bin/apachectl -t
Syntax error on line 94 of /usr/local/apache2/conf/extra/httpd-vhosts.conf:
RewriteCond: bad flag delimiters


2015-01-15 06:10 举报
已邀请:
0

李昂

赞同来自:

94         RewriteCond %{HTTP_USER_AGENT}  ^.*Tomato Bot/1.0* [NC]
0

李昂

赞同来自:

我尝试过  ^.*/Tomato Bot/1.0* [NC]  但是也没用。   还可以 如何尝试。
0

李昂

赞同来自:

94         RewriteCond %{HTTP_USER_AGENT}  ^.*Tomato Bot/1.0* [NC]


^.*Tomato Bot/1.0* [NC]
                 这个位置是不是应该有个 点 (Tomato       Bot)
                                                                    
0

阿铭 管理员

赞同来自:

为什么要有前面的数字?
0

李昂

赞同来自:

阿铭 发表于 2015-1-15 20:13
为什么要有前面的数字?

set nu     排错 使用    查看 第几行 出错
0

阿铭 管理员

赞同来自:

你这问题解决了吗
0

csr

赞同来自:

...为什么这么明显的错误都看不出来...^.*Tomato Bot/1.0*中间不能有空格,想要表示空格用\s...好久没上论坛逛了...直接帮你截图吧:
QQ截图20150116165338.png


QQ截图20150116165544.png


如果想了解更多关于\s等正则相关的,还是去学学perl吧

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: