為啥又要禁止某種瀏覽器的訪問(wèn)呢春畔?
你問(wèn)我我也不知道鹿榜,唯一的想法就是你和某個(gè)瀏覽器公司干仗了辰狡,看他不爽...所以就不想讓他家的瀏覽器訪問(wèn)我家的服務(wù)器...
編輯虛擬主機(jī)配置文件
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
在相應(yīng)的虛擬主機(jī)中加入配置文件如下:
<IfModule mod_rewrite.c>
? ? ? ? ? ? RewriteEngineon
? ? ? ? ? ? RewriteCond%{HTTP_USER_AGENT} ^Firefox/4.0.* [NC,OR]
? ? ? ? ? ? RewriteCond%{HTTP_USER_AGENT} ^Tomato\ Bot/1.0.* [NC]
? ? ? ? ? ? RewriteRule .* - [F]
</IfModule>
寫(xiě)到這就輕松了番刊,大部分語(yǔ)句咱們都是見(jiàn)過(guò)的驹溃,這里不過(guò)指定的是用戶(hù)瀏覽器的信息 ? ? ? ? ? ? ? ?%{HTTP_USER_AGENT},如果瀏覽器是指定的瀏覽器的話城丧,就要執(zhí)行以下操作:
- [F] ? ? ?表示禁止訪問(wèn)
來(lái)看下官方文檔
This example uses the "-" syntax for the rewrite target, which means that the requested URI is not modified. There's no reason to rewrite to another URI, if you're going to forbid the request.
保存配置并重啟Apache服務(wù)器
然后以特定的瀏覽器訪問(wèn),會(huì)顯示被禁止訪問(wèn)