The procedure described here is about blocking a website using .htaccess is specifically used for websites using Apache Web Server Hosting. The stated information should help users who have hosted multiple websites on a single physical server.
It might also be applicable to your website that is hosted on a shared server alongwith other users on a single machine and have an access and control over your domains. It may be a blog, social-networking/bookmarking site, forum etc. that you run on the server and are fed-up due to spammers or scammers and wish to avoid your site being accessible by the particular users. Using the method described in this article, users would be capable of blocking even an entire nation from accessing your website. You simply need to add or edit a single file on the server by adding the enable or disable access to certain audience based upon the IP addresses.
If you have your website hosted on a Linux Apache server, it would have a unique access control file named ‘.htaccess‘, that includes a combination of plain text directives which takes care of enabling or disabling the access to files or folders on a particular website or even some particular directories of the website. Users can even set redirect rules for files, folders or the complete site to a desired page. This feature is particularly useful when a page, file or folder is either renamed, modified or completely deleted. Ideally, the .htaccess file should be in the web root directory viz. public_html. Though some websites might have a different one, hence getting that confirmed from the hosting provider can help you locate the exact file. Few hosts prefer to place the file within the sub-directories as well. As users now-a-days prefer creating sub-domains for forums, blogs etc. a customized .htaccess file can be placed within the main directory of the blog or forum as applicable and from there they can allow or dis-allow access to your site or web-pages.
There are websites available on the Internet who have been regularly updating the IP blocklists for websites hosted on Apache web servers. Many webmasters refer the lists and restrict the website access to scammers, spammers and the IP that are involved in exploiting the servers. A block-list from almost every location such as China, Nigeria etc. is described on the sites.
Now, what you need to do is, simply modify or create an .htaccess file using a text editor of your choice. But, make sure that the text editor allows you to save the file as ANSI or ASCII text. Using an FTP program or via. a cPanel File Manager, you can upload the file over to the server.
You can hide the file by adding a period in the beginning. Incase, you use an FTP program for managing your site, you would probably need to enter a special code or check the box that would enable you to view the hidden files. The widely used WSFTP allows users to add the code -al during the start-up configuration of sites which have been added to the Site List. The code instructs the web-server to show the hidden files such as the ‘.htaccess’. Incase, you happen to use this FTP client, you can access the Site Manager, then create a website connection or choose the one that already exists, choose the Edit option for opening the Site Options, then select the Startup link in Site Options. Look for the input field namely “Remote file mask” then type -al in it, click OK for saving the changes. After following this procedure, you’ll be able to view, edit, upload or download the usually hidden files such as .htaccess.
But incase, you use a web based control panel for uploading or downloading files, it would depend on your hosting provider to allow you to create, view, alter, or upload .htaccess files.
NOTE: If you are using any of the IP addresses mentioned in the block-list, you better check for your own IP address in that list. There are chances that your ISP might be the one in the list hence resulting in an access denial of your site. Further, you need to be careful while installing , editing, creating codes in .htaccess file. Even a minute mistake would generate a 500 error and would restrict anyone from accessing your website.
Like this post ?
Share on your Social Networking Profile ( Facebook, Twitter & Google+ ) and get a flat 10% Recurring discount on our VPS Hosting and Dedicated Servers.
Email us the shared link at : [email protected] or speak to our live chat operator now, by clicking on the “Live Chat” Scroller on the left-hand side of this page and we will provide you with the discount Coupon right away!