Apache

Posts about Apache server.

Preventing Image Bandwidth Theft With .htaccess

21st April 2008

When people link to your images from their own site they are essentially using your bandwidth to show images on their site, this is also known as hotlinking.

The simplest way of preventing people from doing this is to add a .htaccess file to only allow locally linked images to be served. This checks the domain that is linking to your images by using the referrer and if the domain does not equal you own site then a different image is served, in this case blank.jpg.

Using mod_rewrite On Form Parameters

5th March 2008

Using mod_rewrite on websites is fairly straightforward and can create some lovely looking URL structures. Instead of having a URL that contains lots of odd looking parameters like this:

  1. http://www.example.com/example.php?parameter1=value1&parameter2=value2

You can use a .htaccess file to rewrite the URL on the server side in order to shorten this to something like this:

Apache Bench Tool

25th February 2008

The Apache Bench tool can be found in the bin directory of any standard instillation of the Apache HTTP server. It can be used to test the response times of any web server you want and can be useful if you want to stress test a mission critical server before it goes live.

To use the tool open a command prompt (or terminal), navigate the Apache bin folder and find the program ab, this is the Apache Bench tool. The simplest form of running the tool is to use a single URL. However, you must enter a full file name or the tool will give you an invalid URL error.

Avoiding URL Canonicalisation With mod_rewrite And Apache

22nd February 2008

URL canonicalisation is where you have a website with different URLs outputting the same content. When search engine spiders see all this content that is the same they can get confused as to what page to display in search engine result pages. The following URLs, although they are different, actually produce the same content.

Setting Up LDAP With Active Directory On Apache

21st January 2008

Using a simple .htpasswd to password protect a directory or website is fine if you only have a few users, and they don't change very much. However, this quickly becomes impossible to maintain if you have lots of users. For example, if you wanted to secure access to the company Intranet you might spend quite some time trying to update your .htpasswd file. The best way to do this is to transfer all of the user administration over to an LDAP server and then get Apache to communicate with this directly.

Setting php.ini Location In Apache

15th January 2008

After installing PHP on Apache you can use the php.ini file to set various different options to do with PHP. When Apache starts it uses what is contained in this file to set up and run PHP.

On both Windows, Unix and Linux systems Apache will look in a number of default locations for the php.ini file before giving up. You can explicitly tell Apache 2.x where to look for the file by using the PHPIniDir directive in the http.conf file.