Web Development Tutorials for June 2011

Get referring URL in PHP

On the internet, referrer refers to the page that contains the link that was followed to get to the current page. The referrer is set in the HTTP request behind the scenes with usually no intervention from the user. The referrer is not always set by browsers when it should be, and may even be modified (or "spoofed") by the user, so it is not something that can be trusted.

PHP Memory Limit and htaccess

The PHP memory limit will need to changed sooner or later as we start writing and running more resource intensive scripts. The idea of a memory limit is important on a web server since the server may be serving many requests at a given time, and we wouldn't want any one request or script consuming too many resources. Also, it is useful to limit how much memory a script can consume in a setting (like a VPS) where resources like RAM are limited.

Count search engine referrals using web server logs and shell commands

Suppose you want to know how much of your website traffic comes from Google or another search engine. It's very easy if you use Awstats or Google analytics, but what if you haven't configured these tools? Using only the web server log files and some shell commands will enable us to quickly parse log files and give a count of how many referrals we had from a search engine.

For the purposes of this tutorial, we will be assuming an Apache web server, and that the search engine that we are counting the referrals from is Google.

Errors fetching resources using Instant Previews in Google webmaster tools

Google recently launched an instant previews feature in Google webmaster tools. This is a very impressive feature which is undoubtedly useful to webmasters. Instant previews allows webmasters to easily determine if Google is having difficulty in crawling their pages. The reasoning behind it is that if what users see is different from what Googlebot sees, then it might indicate an issue with crawling the website.