Thursday 31 May 2007

Apache Restricting using htaccess

Have you ever made a site you only want a few people to access? Perhaps you have a competitor who keeps viewing your website?

Well, there's several easy ways in apache to do this using the htaccess file and here they are;

Restrict Access by IP Address


Ok, there are several commands to remember when restricting by IP address. The first is that everything needs to go in limit tags;

<limit></limit>

Depending on the information you need you can either specify POST or GET or both as an option of the limit tag (e.g. <limit POST GET>). POST is used when getting user id's and GET is used to get information like hostnames and ip addresses.

The next useful commands are 'deny from' and 'allow from'. You can deny or allow from 'all' or from specific ip addresses or from hostnames e.g.

<limit GET>
deny from all
</limit>

This means no-one has access to this site when placed in the htaccess file.

<h2>Useful Examples</h2>

Allow only from a computer with an ip address of 192.168.1.10;

<limit GET>
deny from all
allow from 192.168.1.10
</limit>

Allow only from computers with an ip address in the range of 192.168.1.*

<limit GET>
deny from all
allow from 192.168.1
</limit>

Allow everyone apart from computers with hostname google.co.uk or ipaddress of 192.168.1.10

<limit GET>
allow from all
deny from google.co.uk
deny from 192.168.1.10
</limit>



www.suffolk-web-design.co.uk/

Wednesday 30 May 2007

The Suffolk Web Design Blog

Welcome to the first entry of the Suffolk Web Design Blog.

My name is Neil Fletcher and I own www.suffolk-web-design.co.uk - a website which I use for my sole trading business Clever SEO and In case you haven't realised (by the name of my website), I'm based in Suffolk.

This Blog is intended to help designers and developers alike. I'll be posting code and tips on how to run linux webservers, partly for my own benefit, but also for anyone who happens across this blog.

If you have any questions, please feel free to contact me here.