Category Archives: htaccess

29Jan/14

Blocking Maliciuos bots from accessing your website

It is always a nuisance when unnecessary bots start hitting your website. It can increase CPU load on your server and may cause MySQL overhead as well, if your website driven by any database. Though the bot access says to be controlled using robots.txt files, most malicious bots do not honor rules defined in robots.txt file. The most reputed bot crawling( like google bot ) can be controlled by robots.txt file or via the web master tools. But for the rest of the bots, the best bet is to block them if they are hitting your website hard.

Following is a sample .htaccess rule, that will help you to block specific bots from accessing your website.

RewriteEngine On
SetEnvIfNoCase User-Agent “BOT” bad_agent
Deny from env=bad_agent

Please note that you should replace “BOT” with corresponding BOT name. For example, the following lines shows access from Bing Bot and Baidu.

Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)”
Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)”

So to block the above two bots, we can add the following lines to .htaccess file of the respective website.

RewriteEngine On
SetEnvIfNoCase User-Agent “bingbot/2.0” bad_agent
SetEnvIfNoCase User-Agent “Baiduspider/2.0” bad_agent
Deny from env=bad_agent

In such way, add “SetEnvIfNoCase” line with corresponding BOT Name before “Deny from” entry for each bots you want to block and that will do the trick.

24Jan/14

ntPHPSelector – short_open_tag

I have noticed many users are reporting miscellaneous issues ( like PHP blank pages ) after switching to additional PHPs. Even many of them could not get phpinfo() working on their custom PHP versions. It is unusual and once ntPHPSelector is installed properly on your server, it should server without any problem. So the first thing you should ensure is, your PHP page should start with <?php . That is because “short_open_tag” is disabled by default in the additional PHP versions by default. So you can either modify your PHP script to have <?php at the beginning or turn on “short_open_tag” in the respective php.in files. Make sure to restart Apache, if you modify php.ini file. Given below are the global php.ini , for the respective versions.

PHP 5.2 /opt/ntphp/php52/lib/php.ini

PHP 5.3 /opt/ntphp/php53/lib/php.ini

PHP 5.4 /opt/ntphp/php54/lib/php.ini

PHP 5.5 /opt/ntphp/php55/lib/php.ini

22Oct/13

How to stop other domain name point to your IP?

I could see that some domains point their host to my IP. For example, if someone type www.other-domain.net, it redirect to my IP: 255.255.255.255 which is address of my web. Since my domain is hosted on a dedicated IP, the domain www.other-domain.net  will load the content of my site.

There is absolutely nothing you can do about people pointing their DNS at your IP address because it is their DNS. One thing they can do is direct people to your website with their domain name in the URL bar. You can easily redirect visitors to the correct domain by putting this in your .htaccess file.

RewriteCond %{HTTP_HOST} !^www.my-domain.com$
RewriteRule ^/?(.*) http://www.my-domain.com/$1 [QSA,R=301,L]

Also try reporting domain registered companies for abuse.

Continue reading