How to block users from accessing your site based on their IP address
Blocking users by IP address is pretty simple with .htaccess.
So here it is the example:
Order allow, deny Deny from 192.168.0.10 Deny from 212.155. Deny from 1.2.3.4 5.6.7.8 127.0.0.1 Allow from all
Let’s take a look at the code line by line:
The first line “Order allow, deny” tells the web server the “Order” in which the Allow and Deny directive will be evaluated. It simply says: Give access to all hosts that are not present in the Deny from list and are present in the Allow from list. With allow, deny order Allow list is looked up first and then the web server checks the deny from list. So as we have allow from all – all access is allowed. Then the allowed access is filtered based on the Deny lists. With allow,deny access is disabled by default.
If we change the order to “deny, allow” then all access is enabled by default and only users in the deny lists are blocked. However as the deny is being processed first allow directives will override any maching settings set in deny directives.
The default Apache order is deny,allow. So you can skip the first line in your .htaccess file if you do not need to change the order in which the Deny and Allow rules are being evaluated by the web server.
So to keep the .htaccess simple you can just use:
Deny from 192.168.0.10 Deny from 212.155.
Basically you can use such rules in your .htaccess file to block a particular user, or a network from accessing your site.
You can put several IP address in a Deny or Allow rule. For example:
Deny from 1.2.3.4 5.6.7.9
The IP addresses must be separated by a space or tab.
You can put entire networks as
Deny from 212.155.
This will block all users which IP addresses start with 212.155
Or to block all access to your site:
Deny from all
And then add another line to enable access only for yourself:
Allow from 1.2.3.4
Where “1.2.3.4” should be replaced with your computer IP address.
Dedicated IP address
Dedicated I.P. address
In this article we will explain what a dedicated I.P. address is, why you would need a dedicated I.P. address and how much a dedicated I.P. address usually costs.
What is a dedicated I.P. address?
A dedicated I.P. address is an I.P. address that is reserved just for you. In other words it is dedicated to you. With a dedicated I.P. address your site is the only site hosted on the I.P. address.
Why would I need a dedicated I.P. address?
You would need a dedicated I.P. address if you need services like private SSL, private name servers or other services that can not run from a shared I.P. address. To have your own web site you do not usually need a dedicated I.P. address.
How much does a dedicated I.P. cost?
Most hosting providers usually charge $1-$5 per month for a dedicated I.P. address.
Will I ever need more than 1 dedicated I.P. address?
If you are running multiple services that require a dedicated I.P. address then you may need multiple dedicated I. P. addresses. For example, if you run multiple sites with private SSL or need private name servers you would need more than 1 dedicated I.P. address.
Dedicated IP hosting and search engines
There has been debate in the SEO industry for awhile regarding whether or not using a dedicated IP address is better than having a shared IP for your website…
- Some SEOs suppose that there really is no good reason to obtain static IP Web hosting. Your site will not perform any better by having its own static IP.
- Some others theorize that your choice of dedicated IP hosting vs. shared hosting might slightly affect your rankings (i.e. it’s a factor considered by search engines).
- Yet others suppose that sharing an IP address with known spam or adult sites raises a warning flag with search engines, so some of them may respond by banning the entire IP address from their index.
Most probably, these fears are greatly exaggerated. Since the majority of sites on the Web are hosted via shared IP, it would be unprofitable to search engines to penalize a site based on IP. Search engines are able to ban anything on a domain name instead of an entire IP neighborhood. So it is search engine safe to use a shared IP hosting. Moreover, almost all hosting will eventually be shared in order to preserve IP addresses.
from buildwebsite4u.com
Who needs a dedicated IP address?
Generally, having a website on a shared IP address will not cause you any harm. However, there are a few cases when a static IP is required…
- Having your own Private SSL Certificate. Secure e-commerce websites need SSL certificates for accepting credit cards online. Web hosts usually offer a shared SSL certificate where clients can share the Web host’s SSL. If you are using your Web hosting provider’s shared SSL you don’t need a static IP.
- Anonymous FTP. It means that anyone using the FTP software can access files in a special directory of your site. It’s called Anonymous FTP because the user name used to access is «anonymous.» Many Web hosting providers require a static IP for the anonymous FTP function to work properly.
- You want to access your website by FTP or Web browser even when the domain name is inaccessible, such as domain name propagation periods.
from buildwebsite4u.com
The difference between shared and dedicated IP addresses
Each computer connected to the Internet is assigned a unique IP address for the purposes of communication. An IP address is a 32-bit numeric address usually expressed as 4 numbers from 0-255 separated by dots, for example 192.168.0.123. There are billions of addresses possible, however, the number is finite.
In the Web hosting industry there are two types of IP address…
- Dedicated IP address (also called static IP) means that a website has its own IP address. Whether you type in your URL or the numeric form of its IP address, both will bring you to the same domain.
- Shared IP address means that multiple websites share the same address. Web servers can determine by the domain entered in a user’s browser which website is being requested. Typing in the IP address will bring you to some kind of generic page instead of the specific site you want.
Due to the rapid increase of the number of registered domain names and the finite number of IP addresses, Web hosting providers are forced to use shared IP’s when possible. In fact, hundreds of websites often share the same address. Static IP hosting is no longer the norm and usually costs more.
from buildwebsite4u.com