0
的.htaccess允許只有當提出要求機器人圖像直接URL訪問以其它方式使用的.htaccess
#Disallowed
#RewriteCond %{REQUEST_URI} !.*\.png$ [NC]
#RewriteCond %{REQUEST_URI} !.*\.jpg$ [NC]
#RewriteCond %{REQUEST_URI} !.*\.gif$ [NC]
#Allowed
RewriteCond %{REQUEST_URI} !=/index.php
RewriteCond %{REQUEST_URI} !.*\.php$ [NC]
RewriteCond %{REQUEST_URI} !.*\.css$ [NC]
RewriteCond %{REQUEST_URI} !.*\.js$ [NC]
RewriteRule . /index.php [L]
的index.php
我在做什麼通過URL來index.php文件正在處理所有圖像網址的index.php並運行下面的條件。如果發現機器人(googlebot,bingbot等)然後顯示圖像,否則運行一些東西。現在我想檢測使用.htaccess
的機器人,並允許圖像直接打開繞過php部分。
if(_bot_detected()){
//echo image
}else{
//redirect user to some page
}
我對網絡編程很陌生。經過很多搜索後,我找不到任何適合我的信息。這是我的第一個問題stackoverflow。感謝您的幫助