How to Block Website(s) using .htaccess ?
The method described here is regarding blocking a web site using .htaccess is specifically used for web sites using Apache Web Server Hosting. The explicit info should help users who have hosted multiple web sites on single physical server.
It might even be applicable to your web site that’s hosted on a shared server alongwith alternative users on one machine and have an access and control over your domains. it should be a blog, social-networking/bookmarking website, forum etc. that you just run on the server and are fed-up because of spammers or scammers and want to avoid your website being accessible by the actual users. Using the method described in this article, users would be capable of blocking even a whole nation from accessing your web site. You simply need to add or edit one file on the server by adding the enable or disable access to certain audience based upon the IP addresses.
If you’ve got your web site hosted on a Linux Apache server, it’d have a unique access control file named ‘.htaccess‘, that has a combination of plain text directives that takes care of enabling or disabling the access to files or folders on specific web site or perhaps some particular directories of the web site. Users will even set redirect rules for files, folders or the entire website to a desired page. This feature is especially helpful when a page, file or folder is either renamed, changed or completely deleted. Ideally, the .htaccess file ought to be within the web root directory viz. public_html. Though some websites might need a distinct one, hence getting that confirmed from the hosting supplier will assist you find the precise file. Few hosts favor to place the file inside the sub-directories as well. As users now-a-days like creating sub-domains for forums, blogs etc. a customized .htaccess file may be placed inside the main directory of the blog or forum as applicable and from there they will permit or dis-allow access to your website or web-pages.
There are web sites out there on the web who often been regularly change the IP blocklists for websites hosted on Apache web servers. Several webmasters refer the lists and restrict the web site access to scammers, spammers and also the IP that are concerned in exploiting the servers.
Now, what you wish to try and do is, merely modify or create an .htaccess file using a text editor of your choice. But, make sure that the text editor permits you to save lots of the file as ANSI or ASCII text. Using an FTP program or via. a cPanel File Manager, you’ll be able to upload the file over to the server.
You can hide the file by adding a period in the starting. Incase, you use an FTP program for managing your website, you’d most likely need to enter a special code or check the box that might alter you to look at the hidden files. The wide used WSFTP permits users to feature the code -al throughout the start-up configuration of web sites that are additional to the site List. The code instructs the web-server to show the hidden files like the ‘.htaccess’. Incase, you happen to use this FTP client, you’ll be able to access the Site Manager, then create a web site connection or select the one that already exists, select the Edit option for opening the Site choices, then choose the Startup link in website Options. Look for the input field particularly “Remote file mask” then type -al in it, click OK for saving the changes. Once following this procedure, you’ll be ready to view, edit, upload or download the typically hidden files like .htaccess.
But incase, you use an web based control panel for uploading or downloading files, it would rely on your hosting supplier to permit you to create, view, alter, or upload .htaccess files.
NOTE: If you’re using any of the IP addresses mentioned in the block-list, you higher check for your own IP address in that list. There are chances that your ISP may be the one in the list hence leading to associate access denial of your web site. Further, you wish 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 web site.