<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Design Talk &#187; General</title>
	<atom:link href="http://www.web-design-talk.co.uk/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.web-design-talk.co.uk</link>
	<description>Web Design &#38; Development Blog</description>
	<lastBuildDate>Wed, 28 Jul 2010 21:50:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Detect AJAX Requests using the x-requested-with header and xmlhttprequest</title>
		<link>http://www.web-design-talk.co.uk/197/detect-ajax-requests-using-the-x-requested-with-header-and-xmlhttprequest/</link>
		<comments>http://www.web-design-talk.co.uk/197/detect-ajax-requests-using-the-x-requested-with-header-and-xmlhttprequest/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 15:32:47 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XAMPP]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=197</guid>
		<description><![CDATA[This is a small snippet of code I came across today, it allows a script to display different content based on how it was requested. This method allows your scripts to remain in a single file, handing both AJAX and normal requests &#8211; it avoids ending up with lots of small PHP files in your [...]]]></description>
			<content:encoded><![CDATA[<p>This is a small snippet of code I came across today, it allows a script to display different content based on how it was requested. This method allows your scripts to remain in a single file, handing both AJAX and normal requests &#8211; it avoids ending up with lots of small PHP files in your AJAX folder, that deals with <strong>ajax requests</strong>.Another use would be a page that has 2 web forms, one AJAX and one normal. You could keep the code for this page in a single file. This method is also useful for security purposes, as it would ensure that requests to your AJAX scripts are via AJAX only. It also has uses for writing unobtrusive JavaScript &#8211; maybe ensuring that an AJAX enabled web form would work when javascript is disbaled.</p>
<p>For example, the below code would display different code depending on if the request for the page was made via AJAX or directly via a browser.</p>
<pre class="brush: php;">
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    //This is an AJAX request, do AJAX specific stuff
}
else {
    //This is not an AJAX request E.g. display normal page content.
}
</pre>
<p>In some code I was working on today, I saw a neater way of achieving the above, this would be included in your common config file:</p>
<pre class="brush: php;">
define('IS_AJAX_REQUEST', isset($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');

if(IS_AJAX_REQUEST) {
    //This is an AJAX request, do AJAX specific stuff
}
else {
    //This is not an AJAX request E.g. display normal page content.
}
</pre>
<p>There&#8217;s an HTTP variable set called <strong>HTTP_X_REQUESTED_WITH</strong>, which will is set to &#8216;<strong>XMLHttpRequest</strong>&#8216; if the request method is via AJAX. This is method is untested with JavaScript frameworks other than JQuery, so may not work (but I don&#8217;t see any reason at all why it wouldn&#8217;t!).</p>
<p>It&#8217;s also worth noting that not all web servers include this variable and sometimes omit this specific $_SERVER paramter. Use vardump($_SERVER) to check that the <strong>HTTP_X_REQUESTED_WITH</strong> is present.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/197/detect-ajax-requests-using-the-x-requested-with-header-and-xmlhttprequest/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Prevent Duplicate Content using the Canonical Url Tag</title>
		<link>http://www.web-design-talk.co.uk/164/prevent-duplicate-content-using-the-canonical-url-tag/</link>
		<comments>http://www.web-design-talk.co.uk/164/prevent-duplicate-content-using-the-canonical-url-tag/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 14:34:39 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=164</guid>
		<description><![CDATA[I was recently doing an seo audit of a small ecommerce website. One of the first things I did was to do a &#8216;site:www.domain.com&#8217; in Google. Amazingly, the site in question has approximately 8200 pages indexed in Google. This was quite surprising when the store only sold less than 1500 unique products. The site used [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently doing an seo audit of a small ecommerce website. One of the first things I did was to do a &#8216;site:www.domain.com&#8217; in Google. Amazingly, the site in question has approximately 8200 pages indexed in Google. This was quite surprising when the store only sold less than 1500 unique products. The site used a horrible ecommerce module bolted onto phpnuke and has a horrible url structure, appending lots on unecessary querystring data onto the url.</p>
<p>Whilst looking through the Google results for this site the majority of pages were as follows:</p>
<pre class="brush: xml;">
/index.php?tab=123&amp;txtSearch=ALL&amp;List=oasc&amp;Sort=PName%2CPName&amp;CreatedUserID=1&amp;pageindex=40&amp;Language=en-GB
</pre>
<p>The site has an advanced search page, whereby you can sort products using a variety of options such as ascending order, descending order, size, price etc. This is bad for a number reasons, but mainly due to duplicate content (not to mention lower serps ranking, traffic loss and decreased page relevancy) . A page of results in ascending and descending order is essentially the same page, simply a different view of your data &#8211; you can help search engines via using the relatively new <strong>canonical url link tag. </strong></p>
<p>To illustrate I&#8217;ll use an example of a typical category page, whereby you can sort a list of products in ascending and descending order, leaving you with a number of urls as follows:</p>
<pre class="brush: xml;">

http://www.shop.com/category.php?catName=Shirts&amp;sortOrder=ASC
</pre>
<p>In this example the part of the querystring creating the duplicate content would be the sortOrder parameter &#8211; as you would want your seperate categories indexed.</p>
<p>The solution is quite simple. In your head tag add the following:</p>
<pre class="brush: xml;">
&lt;link rel=&quot;canonical&quot; href=&quot;http://www.shop.com/category.php?catName=Shirts&quot; /&gt;
</pre>
<p>By adding this to your category page you are telling search engines (currently Google, Yahoo, Ask and Bing use this tag) that this page is a copy of http://www.shop.com/category.php?catName=Shirts. Indicators such as Google Pagerank are also transferred to your preferred url.</p>
<p>The <strong>canonical url tag</strong> has many uses and can be used to help with the following issues:</p>
<ul>
<li>Pages that contain session IDs appended to the querystring</li>
<li>Search results pages that append search data to the querystring</li>
<li>Print versions of page</li>
<li>Duplicate content for www. and non-www. pages 0 in your canonical tag you would include your preferred url</li>
<li>Same content contained in multiple categories &#8211; E.g. a product contained in multiple categories on an online store</li>
<li>Removing affiliate ids in the url</li>
<li>Preventing multiple pages of a discussion topic with comments from being indexed E.g. shop.com/post.php?id=123&amp;page=1</li>
</ul>
<p>You can read more about the canonical tag at the official <a title="Specify Your Canonical" href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html" target="_blank">Google Webmaster Blog.</a> <a title="Canonical Link Tag" href="http://www.mattcutts.com/blog/canonical-link-tag/" target="_blank">Matt Cutt&#8217;s also has a 20 minute video</a> explaing the canonical tag in more depth.</p>
<p>The main point to consider is that the canonical tag is simply a hint and not a directive. It is another method to give search engines help in indexing your content. This is very useful when working on existing sites already indexed by Google. However, on new sites bit more planning can help. For instance, in a  previous article I covered <a title="301 redirects for seo using htaccess" href="http://www.web-design-talk.co.uk/20/301-redirects-for-seo-using-htaccess/" target="_blank">301 redirects for seo using htaccess</a> &#8211; how to set a prefferred version of your site via htaccess. On an ecommerce store you could avoid appending search data to the querystring.</p>
<p>EDIT: wordpress and all in one seo plugin generate canonical link tags for blog posts. For example, comments are seperated into multiple pages E.g</p>
<pre class="brush: xml;">

http://www.web-design-talk.co.uk/157/how-to-deal-with-difficult-clients-using-split-testing/comment-page-1/#comment-344
</pre>
<p>With the actual content being at:</p>
<pre class="brush: xml;">

http://www.web-design-talk.co.uk/157/how-to-deal-with-difficult-clients-using-split-testing
</pre>
<p>If you have a quick look at the source code to the comments page you&#8217;ll see the following has been added:</p>
<pre class="brush: xml;">
&lt;pre id=&quot;line34&quot;&gt;&lt;link rel=&quot;canonical&quot; href=&quot;http://www.web-design-talk.co.uk/157/how-to-deal-with-difficult-clients-using-split-testing/&quot; /&gt;
</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/164/prevent-duplicate-content-using-the-canonical-url-tag/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Deal With Difficult Clients Using Split Testing</title>
		<link>http://www.web-design-talk.co.uk/157/how-to-deal-with-difficult-clients-using-split-testing/</link>
		<comments>http://www.web-design-talk.co.uk/157/how-to-deal-with-difficult-clients-using-split-testing/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 20:23:28 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=157</guid>
		<description><![CDATA[Dealing with awkward clients using split testing]]></description>
			<content:encoded><![CDATA[<p>Sometimes you can be in the process of trying to tell a client that their idea simply won&#8217;t work. Be it a flimsey campaign idea of extra design element that you know through experience will not work and produce the desired KPIs for a client project. You can even show the client links, articles and examples of why their idea will fail to deliver results. However, if this is potential or existing client they are likely to go elsewhere, to a company willing to follow their every word without consideration &#8211; I have come across web companies who will do this.</p>
<p>Recently an existing client came to me asking why his site isn&#8217;t showing up when people search for a particular long tail search term. Now, his existing site used a pretty awful content management system that didn&#8217;t even allow him to set his own pages titles or meta descriptions. Furthermore, he was lacking inbound links, which people ranked above him did have. This all sounds simple and straightforward but even after I had explained (in quite clear and non technical langauge may I add) the merits of good SEO and one page content the client simply wouldn&#8217;t accept this as a solution. He had his own short term and less costly solutions &#8211; basically revolving around the the idea me resubmitting his sitemap page to all the major search engines each day. I&#8217;m not debating that submitting a sitemap isn&#8217;t a good idea, because it is. However, the client&#8217;s main KPI for this project was increased site enquiries.</p>
<p>After much discussing this we had both come to a bit of an awkward silence &#8211; not a good thing if you&#8217;ve ever experinced this in client meetings. For some reason I remebered back to my unoversity days where I had read something about <a title="Split Testing " href="http://en.wikipedia.org/wiki/A/B_testing" target="_blank">split testing (or A/B testing)</a> &#8211; where you can turn a negative situation into a positive one.This is quite a delicate situation to be in as it can damage your client relationship quite quickly.</p>
<p>The idea was to use the client&#8217;s idea for a period of time and my idea for a period of time. At the start of this I would install Google Analytics (I was tempted to use Google&#8217;s website optimizer, but decided against it) and let the statisitics do the talking &#8211; as a no one can argue with statistics.</p>
<p>This method has been very useful previously when demonstrating the merits of creating a dedicated landing page for Google Adword campaigns, but can be used anywhere if you&#8217;re willing to a little bit extra.</p>
<p>This method is beneficial for the following reasons:</p>
<ul>
<li>The client&#8217;s idea are being dismissed as wrong (however right you think you are)</li>
<li>You are showing the client that you care enough to demonstrate your ideas</li>
<li>Occassionaly the client will back down as soon as you explain your plan of attack</li>
<li>It prevents those awful awkward silences</li>
<li>You have a real world example to use in your other client meetings</li>
<li>You are speaking the clients language in that you are demonstrating how your actions lead to increased conversions</li>
<li>You are being direct, which I personally think is alwasy a good thing &#8211; as such statistics are often a huge eye opener for clients</li>
<li>If and when the client comes to the same conslusion as you, they won&#8217;t blame you</li>
</ul>
<p>There is always the arguement that the client is the client and that it&#8217;s all business at the end of the day. However, I personally pride myself on doing things properly. Others will say just get on with, do what the client wants and forget about it &#8211; you can only offer your opinion. This is a good point but can still damage your client relationships when they return later on and you need to charge them again. It all depends if you require long or short term client relationships &#8211; as they are definately an investment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/157/how-to-deal-with-difficult-clients-using-split-testing/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Tracking Twitter Performance Using Google Analytics</title>
		<link>http://www.web-design-talk.co.uk/138/tracking-twitter-performance-using-google-analytics/</link>
		<comments>http://www.web-design-talk.co.uk/138/tracking-twitter-performance-using-google-analytics/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 20:47:38 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[google analytics]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=138</guid>
		<description><![CDATA[If you use the ever popular twitter there&#8217;s a high chance you&#8217;ll be linking to your company webiste or personal blog in your tweets or profile link. As the aim is use twitter as a marketing tool to drive traffic, you can use Google Analytics to track the link you placed the twitter profile &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>If you use the ever popular <a href="http://www.twitter.com" target="_blank">twitter</a> there&#8217;s a high chance you&#8217;ll be linking to your company webiste or personal blog in your tweets or profile link. As the aim is use twitter as a marketing tool to drive traffic, you can use Google Analytics to track the link you placed the twitter profile &#8211; just like an email campiagn or PPC advert</p>
<p>If you use Twitter as a marketing tool to drive traffic to your site then you should treat it in exactly the same way as you would a newsletter, a <acronym title="Pay Per Click">PPC</acronym> advert or a banner and track each Tweet’s performance beyond simple click data. How many visits do you get, how long do they stay on your site, how deep do they go, what is the bounce rate like and how much revenue do they generate?</p>
<p>The benefit to &#8216;tagging&#8217; this link is that Google Analytics will record more than use basic click data &#8211; you can record a whole host of advanced user data such as how they navigate your site and length of visit. By default Google will track such links, but traffic from services such as bit.ly will be dumped into the direct traffic area of Google Analytics. The steps to get the latter up and running are quite simple:</p>
<p>1: Go to <a title="URL Builder" href="http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&amp;answer=55578" target="_blank">Google&#8217;s URL builder</a> to generate an url . Enter the following information:</p>
<p><strong>Website URL</strong>: your website address<strong> </strong></p>
<p><strong>Campaign Source: </strong>enter a relevant source here to identify your campaign E.g. twitter</p>
<p><strong>Campaign Name: </strong>enter a name used to identify the campaign, this is used to identify the campaign in Google Anlytics E.g. twittertracking</p>
<p>2: Click generate URL and something similar to the following will be created: http://www.web-design-talk.co.uk/<strong>?utm_source=twitter&amp;utm_medium=social&amp;utm_campaign=twittertrack</strong></p>
<p><strong><br />
</strong></p>
<p>3: If posting to twitter you can paste this URL directly in the tweet box, as twitter will automatically shorten this url.</p>
<p>4: After approximately 24 hours data will appear in your analytics account. Simply navigate to Traffic Sources. If you&#8217;ve used the same terms to build the url as above you&#8217;ll see an entry called &#8216;twitter / social&#8217;. You can also view information by navigating to Traffic Sources &gt; Campaigns where you can click the campiagn name (&#8216;twittertrack&#8217; was used in he example above).</p>
<div id="attachment_139" class="wp-caption alignnone" style="width: 766px"><img class="size-full wp-image-139" title="tracking-twitter-traffic" src="http://www.web-design-talk.co.uk/wp-content/uploads/2009/11/tracking-twitter-traffic.jpg" alt="Google Analytics Once Tracking is Installed" width="756" height="507" /><p class="wp-caption-text">Google Analytics Once Tracking is Installed</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/138/tracking-twitter-performance-using-google-analytics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting htaccess Mod-rewrite rules working locally with XAMPP</title>
		<link>http://www.web-design-talk.co.uk/126/getting-htaccess-mod-rewrite-working-locally-with-xampp/</link>
		<comments>http://www.web-design-talk.co.uk/126/getting-htaccess-mod-rewrite-working-locally-with-xampp/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 00:28:46 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[XAMPP]]></category>
		<category><![CDATA[htaccess file]]></category>
		<category><![CDATA[relative path]]></category>
		<category><![CDATA[rewrite rule]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=126</guid>
		<description><![CDATA[After spending a whole 2 hours of my life trying to get Apache mod-rewrite rules working with XAMPP on a local computer, I thought I&#8217;d share my results as I seemingly tried everything. The problem, I have a simple mod-rewrite rule in my htaccess file. When I upload this to my online web host everything [...]]]></description>
			<content:encoded><![CDATA[<p>After spending a whole 2 hours of my life trying to get Apache mod-rewrite rules working with <a href="http://www.apachefriends.org/en/xampp.html" target="_blank">XAMPP</a> on a local computer, I thought I&#8217;d share my results as I seemingly tried everything. The problem, I have a simple mod-rewrite rule in my htaccess file. When I upload this to my online web host everything is fine &#8211; the working htaccess file  for my online host:</p>
<pre class="brush: jscript;">
RewriteBase /
RewriteEngine on
RewriteRule amnesia/resetpass(.*) recover-password.php$1 [PT]
</pre>
<p>So typing in <code>www.domain.com/amnesia/resetpass</code> does a simple re-write to <code>www.domain.com/recover-password.php</code>, without the user ever knowing. All is fine. However, when I treid to get this seemingly simple rule to work with XAMPP I ran into problems, getting 404 and 500 responses from the server &#8211; obviously quite a pain as this essentially means I can&#8217;t test the site using my own web server (E.g. localhost). The site hosted from my computer via the normal setup E.g. xampp/htdocs/mysite. I&#8217;ll jump straight to the solution and then explain exactly what things were changed &#8211; the working htaccess file is below:</p>
<pre class="brush: jscript;">
RewriteEngine on
RewriteBase /mysite
options +FollowSymLinks
RewriteRule amnesia/resetpass(.*) recover-password.php$1 [PT]
</pre>
<p>Firstly, the extra line that uses the <code>+FollowSymLinks</code> directive was added. To explain this I&#8217;ll quote straught from the <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">Apache documentation</a>:</p>
<blockquote><p>To enable the rewriting engine           for per-directory configuration files, you need to set           &#8220;<code>RewriteEngine On</code>&#8221; in these files           <strong>and</strong> &#8220;<code>Options           FollowSymLinks</code>&#8221; must be enabled. If your           administrator has disabled override of           <code>FollowSymLinks</code> for a user&#8217;s directory, then           you cannot use the rewriting engine. This restriction is           needed for security reasons.</p></blockquote>
<p>The re-write base has been changed to the relative path of the website directory. To finish up, open the http.conf file (the default settings for XAMPP, that get overwritten with you .htaccess file rules on a directory basis), located by default at C:\xampp\apache\conf\http.conf. Find all occurances of <code>AllowOverride None</code> and change it to <code>AllowOverride All</code>. After restarting XAMPP everythign should work. In a nutshell changing the AllowOverride directive in the http.conf file decalres which directives in .htaccess files can override directives from httpd.conf, this is <a href="http://vr-zone.com/manual/en/mod/core.html#allowoverride" target="_self">discussed in more dept over here</a>, but basically by having this directive set to None, you&#8217;re stopping individual htaccess files from working locally.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/126/getting-htaccess-mod-rewrite-working-locally-with-xampp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SEO Friendly URLs With Mod Rewrite</title>
		<link>http://www.web-design-talk.co.uk/116/seo-friendly-urls-with-mod-rewrite/</link>
		<comments>http://www.web-design-talk.co.uk/116/seo-friendly-urls-with-mod-rewrite/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 16:22:22 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=116</guid>
		<description><![CDATA[So called &#8216;dirty URLS&#8217; (E.g. www.domain.com/products.asp?id=45&#38;cat=34&#38;mode=view) not only look untidy but also pose a security risk as they expose the underlying technology used, in this case, ASP. A much preferred URL in this case would be www.domain.com/product/45 or even better, www.domain.com/product/product_keywords-here. The latter URL structure not only improves useability for your site (the URL makes [...]]]></description>
			<content:encoded><![CDATA[<p>So called &#8216;dirty URLS&#8217; (E.g. www.domain.com/products.asp?id=45&amp;cat=34&amp;mode=view) not only look untidy but also pose a security risk as they expose the underlying technology used, in this case, ASP. A much preferred URL in this case would be www.domain.com/product/45 or even better, www.domain.com/product/product_keywords-here. The latter URL structure not only improves useability for your site (the URL makes more sense to the user) and is <a href="http://www.malcolmcoles.co.uk/blog/seo-friendly-urls-myth-and-fact/" target="_blank">argued to improve search engine rankings</a>.  There is a lot of debate on this subject, but everyone agress that these so called pretty URL&#8217;s don&#8217;t hurt anything and mainly improve user experience.  Google has also recently <a href="http://www.youtube.com/watch?v=gRzMhlFZz9I" target="_blank">posted a video</a> (obviously not giving much away) saying that SEO friendly URL&#8217;s do in fact make a small difference and don&#8217;t hurt SERPs&#8217;</p>
<p>Take the example of this very blog. Pretty urls are used to display the post title and id within the url. There is the option to simply include the title, but this has been proven to <a href="http://dougal.gunters.org/blog/2009/02/04/efficient-wordpress-permalinks">slow down general performance</a> of your blog. I digress, let&#8217;s get onto some examples where simple URL rewriting with mod rewrite is useful.</p>
<p><span id="more-116"></span></p>
<p>Currently at work I&#8217;m working on an internal administration system to handle invoices, customers, quotes &#8211; basically everything to replace a paper based admin system, I was given the brief to mimick the <a href="http://basecamphq.com/" target="_blank">basecamphq project management system</a>. With the except of several pages I&#8217;ve managed to keep the URL fairly clean looking using a directory structure (E.g. www.domain.com/clients) and <a href="http://www.tizag.com/phpT/postget.php" target="_blank">POST data</a>. However, a couple of URL&#8217;s do look ugly, namely the order detail page &#8211; www.domain.com/orders_detail.php?orderRef=1234. I thought this would be the perfect excuse to use some URL rewriting. Reading some articles, you feel like you need a degree in regular expressions and LAMP setups to get this working, but it&#8217;s far from the truth, especially with the help of some online regex generaters.</p>
<p>So currently I have an order details page that simply fetches data for the order reference contaojed within the querystring. I&#8217;ll assume you know how to do the basics. I&#8217;ll get straight into it, here&#8217;s the familiar .htaccess file contents with a rule for my orders_detail.php page:</p>
<pre class="brush: jscript;">
RewriteBase /
RewriteEngine on
RewriteRule ^order/detail/([^/]*)$ /orders_detail.php?orderRef=$1 [QSA,L]
</pre>
<p>To keep this article brief I&#8217;ll leave out the detail on what everything actually means but it basically redirects the url www.domain.com/orders/detail/1234 to  www.domain.com/orders_detail.php?orderRef=1234, all without the user knowing, obviously the former URL is kept within the address bar too. It really is that simple!</p>
<p>However, as with anything good there are other factors to considor. If you use relative url paths in your page you&#8217;ll need to these to absolute paths. Take the example of my code to include a simple CSS file into my orders_detail.php page:</p>
<pre class="brush: xml;">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/main_compiled.css&quot; /&gt;
</pre>
<p>This worked fine when using the old URL, but now the page looks for www.domain.com/order/detail/css/main_compiled.css, which doesn&#8217;t exist. You have several options here. You can use abolute paths for all your links, a <a href="http://www.w3schools.com/TAGS/tag_base.asp" target="_blank">base href </a>within the header tag or add a rewrite base variable to each page and out it before the link. E.g.</p>
<pre class="brush: php;">
define('BASE_PATH', '/');
</pre>
<p>and using it to a fix a hyperlink:</p>
<pre class="brush: xml;">
&lt;a href=&quot;&lt;?php echo MOD_REWRITE_BASE_PATH; ?&gt;img/logo.png&quot;&gt;View Logo&lt;/a&gt;
</pre>
<p>That&#8217;s it!</p>
<p>Another place I use URL rewriting is to give custom news systems, blogs and events pages a little extra. For example, we&#8217;ll turn www.domain.com/news_detail.php?postID=1234 into www.domain.com/34/post-title-here-with-keywords &#8211; wordpress style. Again, I&#8217;ll take the example of a news system, where we have a front page with news listing and a detail page with the full news item. Firstly let&#8217;s dealwith outputting our pretty url on the front news page.</p>
<p>Currently we have a list of links with a post id attached to the link. Clicking rhe link will tajke you to a detail page. <a href="http://web-design-talk.co.uk/examples/4/old/latest-news.php">See here</a> for the progress so far. However, at the minute our links page only has the post id and nothing mentioning the post title. This is simply a case of adding another variable (title) to the querystring, <a href="http://www.web-design-talk.co.uk/examples/4/withtitle/latest-news.php">see here for an updated page</a>. For simplicity I&#8217;ve used a single title (you would normally fetch the title from a database) and included hyphens to seperate words (search engines recognioze this as a space). Adding hyphens between words is a simply a case of running the title through a function. As the one I use is a at work I shamelessly used the one from the <a href="http://htmlblog.net/seo-friendly-url-in-php/" target="_blank">html blog.</a> Here&#8217;s the PHP to generate our links page (note, I used a simple loop to output the links for quickness, in reality this list would come from a database):</p>
<pre class="brush: php;">
function friendlyURL($string){
$string = preg_replace(&quot;`\[.*\]`U&quot;,&quot;&quot;,$string);
$string = preg_replace('`&amp;(amp;)?#?[a-z0-9]+;`i','-',$string);
$string = htmlentities($string, ENT_COMPAT, 'utf-8');
$string = preg_replace( &quot;`&amp;([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i&quot;,&quot;\\1&quot;, $string );
$string = preg_replace( array(&quot;`[^a-z0-9]`i&quot;,&quot;`[-]+`&quot;) , &quot;-&quot;, $string);
return strtolower(trim($string, '-'));
}

$prettyTitle =  friendlyURL(&quot;seo friendly urls with mod rewrite&quot;);

for ($i = 1500; $i &lt;= 1520; $i++) {
  echo &quot;&lt;p&gt;&lt;a href=\&quot;news-detail.php?postID=$i&amp;amp;title=$prettyTitle\&quot;&gt;New Item Headline&lt;/a&gt;&lt;/p&gt;&quot;;
}
</pre>
<p>Now comes the time to update our htacess file with the following rule:</p>
<pre class="brush: jscript;">
# This is a comment: Rewrite news-detail.php?postID=1234&amp;title=text-text to /1234/text-text
RewriteRule ^(.*)/([a-zA-Z-]+)$ /news-detail.php?postID=$1&amp;title=$2 [QSA,L]
</pre>
<p>On the page listing I&#8217;ve amened how our links are printed out (using the new pretty structure) and to show its working added an example of when an invalid article id is entered (E.g. when fetching it from our database). E.g. lets say article id 1503 is not in our database.</p>
<pre class="brush: php; html-script: true;">
&lt;?php
if ($_REQUEST['postID']=='1503') {

echo &quot;Article Not Found!&quot;;

} else {
?&gt;

    	&lt;h1&gt;&lt;?php echo str_replace(&quot;-&quot;,&quot;&amp;nbsp;&quot;,$_REQUEST['title']); ?&gt; (ID &lt;span class=&quot;highlight&quot;&gt;
                       &lt;?php echo intval(htmlentities($_REQUEST['postID'])); ?&gt;&lt;/span&gt;)&lt;/h1&gt;
        &lt;p&gt;Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab
        illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut
        odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum
        quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat
        voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?
        Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo
        voluptas nulla pariatur?&lt;/p&gt;

&lt;?php }  ?&gt;
</pre>
<p>That&#8217;s it in all honesty. I can&#8217;t show you an example on this server as WordPress uses the same structure. You can <a href="http://www.web-design-talk.co.uk/examples/4/4.zip" target="_blank">download the source files</a> to play with.</p>
<p>This technique can easily be used in various forms for ecommerce sites &#8211; E.g. domain.com/product/1234/bath-tub and in blogs or news systems. It&#8217;s a big subject andf I&#8217;ve only covered the basics here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/116/seo-friendly-urls-with-mod-rewrite/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CSS Sprities and Website Optimization</title>
		<link>http://www.web-design-talk.co.uk/88/css-sprities-and-website-optimization/</link>
		<comments>http://www.web-design-talk.co.uk/88/css-sprities-and-website-optimization/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 21:10:19 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[sprities]]></category>
		<category><![CDATA[website optimisation]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=88</guid>
		<description><![CDATA[One of the latest and most well established design practices are CSS sprites. This is the practice of combing multiple images into a larger and single, composite image. By using the CSS background-position property selected portions of that master image (or sprite) are displayed. The main issue here is how can a larger image witha [...]]]></description>
			<content:encoded><![CDATA[<p>One of the latest and most well established design practices are CSS sprites. This is the practice of combing multiple images into a larger and single, composite image. By using the <a href="http://www.w3schools.com/css/pr_background-position.asp">CSS background-position property</a> selected portions of that master image (or sprite) are displayed. The main issue here is how can a larger image witha larger file size be beneficial, especially when compared to several smaller images? The answer lies in HTTP requests and <a href="http://yuiblog.com/blog/2006/11/28/performance-research-part-1/">Yahoo&#8217;s 80/20 rule</a> explains this much better than I could! To summarise, the numbers of HTTP requests to the websites is drastically cut, thus loading the page much faster in  single request. Another major beenfit is that not Javascript is required for mouseover code, so you can make image rollovers easily. I have used this technque in the past, but like a lot of people never knew it was called sprites.</p>
<p>In fact, using sprites are so effective many of the internets biggest site&#8217;s are using them, all in slightly different ways. On such sites a truely huge number of requests are saved every day. For example, Youtube, Google, AOL,  Amazon and Apple all use CSS sprites. Take the mimilist example of Google (left):</p>
<div class="wp-caption alignleft" style="width: 160px"><img title="Google CSS Sprite" src="http://www.google.ca/images/nav_logo3.png" alt="Google CSS Sprite" width="150" height="105" /><p class="wp-caption-text">Google CSS Sprite</p></div>
<p>Youtube, does things slightly different and uses a absolutely <a href="http://s.ytimg.com/yt/img/master-vfl89407.png">massive sprite 2800px in height</a>! You&#8217;ll notice that some sprites are tightly packed together and other have spacing around each image. This is to allow for browser based text sizing, that would otherwise display multiple background images. A good example of planning for such an occurance is <a href="http://digg.com//img/menu-current.gif">Digg&#8217;s sprite</a>, where each image is highly spaced out.</p>
<p>The CSS is relatively simple. Take the example of a simple unordered list with a different image for each item. I made a <a href="http://web-design-talk.co.uk/examples/3/yada.png">very simple sprite </a>and applied the background-position property to each link class. Here&#8217;s the simple HTML used for the list:<span id="more-88"></span></p>
<pre class="brush: xml;">
&lt;ul id=&quot;sprites&quot;&gt;
	&lt;li&gt;&lt;a class=&quot;exclamation&quot; href=&quot;#&quot;&gt;Top Product&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a class=&quot;hot&quot; href=&quot;#&quot;&gt;Sizzlin Offers&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a class=&quot;offer&quot; href=&quot;#&quot;&gt;Special Deals&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>..and the CSS:</p>
<pre class="brush: css;">#sprites li {
 	list-style-type:none;
	font-size:1.1em;
	display: inline;
}
#sprites li a {
	background-image:url('yada.png');
	background-repeat:no-repeat;
	padding:5px 35px;
	line-height:35px;
	text-decoration: none;
	color: #333;
}
#sprites li a:hover {
text-decoration: underline
}
#sprites li a.hot {background-position:0px -165px}
#sprites li a.exclamation { background-position: 0px 0px; }
#sprites li a.offer { background-position: 0 -82px; }</pre>
<p>The <a href="http://web-design-talk.co.uk/examples/3/">final result</a> is a horizontal list, using a single image for the icons &#8211; no CSS hacks required for correct display in all the latest browsers! I won&#8217;t bother explaing the HTML or CSS as is self explanatory and very simple.</p>
<p>I personally find CSS sprites most useful for application icons as I can easily add a new icon class and set the background position accordingly. For instance, I&#8217;m currently working on a project that uses a lot of the fabulous <a href="http://www.famfamfam.com/lab/icons/silk/">famfamfam silk icons</a> and have used a <a href="http://www.famfamfam.com/lab/icons/silk/previews/index_abc.png">sprite similar to that on their site</a>. While this is a lot of work initially, my recent discovery the <a href="http://spritegen.website-performance.org/">sprite generator</a> has limited this work load.</p>
<p>Sprites can be used a for avriety of things, including simple image rollovers &#8211; see a quick example I put together using a simple hyperlink and a single background image (image from <a href="http://michaelmknight.deviantart.com/art/Virus-Shield-59357349">devianrt</a>). When I hover on the logo the background-position property simply shifts the spirite to right. You can view the <a href="http://web-design-talk.co.uk/examples/3/css-sprite-single-image.php">result right here</a>!</p>
<p>As with everything, you can take this idea a stage further and apply some JQuery to the mix to <a href="http://www.alistapart.com/articles/sprites2">create an amazing Flash like menu</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/88/css-sprities-and-website-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reasons to let Google Host your JQuery Files</title>
		<link>http://www.web-design-talk.co.uk/81/reasons-to-let-google-host-your-jquery-files/</link>
		<comments>http://www.web-design-talk.co.uk/81/reasons-to-let-google-host-your-jquery-files/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 20:09:08 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=81</guid>
		<description><![CDATA[It&#8217;s often the case that I see busy sites hosting copies of the JQuery library locally. E.g &#60;script src=&#34;/js/jQuery.min.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; The preferred and better way is to host your JQuery through Google E.g. &#60;script src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; So, why is this better? Well there are several valid reasons: CDN (Content Delivery Network) &#8211; Google&#8217;s datacenters are [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s often the case that I see busy sites hosting copies of the JQuery library locally. E.g</p>
<pre class="brush: jscript;">&lt;script src=&quot;/js/jQuery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre>
<p>The preferred and better way is to host your JQuery through Google E.g.</p>
<pre class="brush: jscript;">&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre>
<p>So, why is this better? Well there are several valid reasons:</p>
<p><strong>CDN (Content Delivery Network) &#8211; </strong>Google&#8217;s datacenters are located over a range of locations and when a user requests content the closest location is automatically chosen. This is better because it does not force users to download from a single server location (E.g your server) and the chances are Google will be able to serve content faster than your webhost. A similar theory is used for the popularweb based game called <a href="http://www.quakelive.com" target="_blank">quakelive</a>. Usually <a href="http://en.wikipedia.org/wiki/Content_delivery_network" target="_blank">CDN</a>&#8216;s are a service you pay for, but you&#8217;re getting this free through Google!</p>
<p><strong>Less server load &#8211; </strong>When all your website&#8217;s files are located on a single server, downloading them simulainiously increases server load and some users will recieve delays while files download. By having an external location for your JQuery library the latter is not an issue.</p>
<p><strong>Improved caching &#8211; </strong>This is the biggest benefit as users will not have to re-download content. Hosting JQuery on your own server will cause a first time visitor to download the whole file, even if they have several copies of the same file from other sites. Through Google&#8217;s CDN, re-requests for the same file will result in a response to cache the file for up to one year, as it understands that it is a repeat request for a duplicate file.</p>
<p><strong>Local Bandwidth savings &#8211; </strong>by letting Google host the file for you, you are in essence saving bandwidth. For personal sites this may not be an issue, but busy sites will notice significant bandwidth savings.</p>
<p>Google actually suggests using a .load() function to load the library (see below), but this not only interrupts JQuery&#8217;s killer feature (document.ready), but also causes an extra <a href="http://en.wikipedia.org/wiki/HTTP_Requests" target="_blank">HTTP request</a>. Personally I prfer the old fashioned script method, even though there are <a href="http://stackoverflow.com/questions/208869/what-are-advantages-of-using-google-loadjquery-vs-direct-inclusion-of-ho" target="_blank">several other valid reasons</a> to use the .load() method.</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;
        src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  google.load(&quot;jquery&quot;, &quot;1.3.2&quot;);
  google.setOnLoadCallback(function() {
  });
&lt;/script&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/81/reasons-to-let-google-host-your-jquery-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fixing Common W3C Validation Errors and SEO</title>
		<link>http://www.web-design-talk.co.uk/79/fixing-common-w3c-validation-errors-for-seo/</link>
		<comments>http://www.web-design-talk.co.uk/79/fixing-common-w3c-validation-errors-for-seo/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 18:21:00 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[xHTML Validation]]></category>
		<category><![CDATA[semantic code]]></category>
		<category><![CDATA[w3c validation]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=79</guid>
		<description><![CDATA[Yet another thing to check when doing SEO is that your site validates via the w3c validation checker. A site that is xHTML valid will recieve more frequent search engine crawls and more importantly, longer crawl times. I won&#8217;t bore you with further details about why validation is a good thing (it&#8217;s a huge subject), [...]]]></description>
			<content:encoded><![CDATA[<p>Yet another thing to check when doing SEO is that your site validates via the <a title="w3c validator" href="http://validator.w3.org/" target="_blank">w3c validation checker</a>. A site that is xHTML valid will recieve more frequent search engine crawls and more importantly, longer crawl times. I won&#8217;t bore you with further details about why validation is a good thing (it&#8217;s a huge subject), but if you must there is a great article about the <a href="http://validator.w3.org/docs/why.html">subject right here</a>. Creating a site to an xHTML valid standard encourages better coding practice and more <a href="http://www.seoblogger.co.uk/serps/the-benefits-of-using-semantic-code.html">semantic coding</a> &#8211; making your site easier to crawl. You are also giving your site a betttr chance of displaying the same across multiple and future browsers.</p>
<p>Another less known theory is that spiders get full when crawling a page, semantic coding practice will allow for cleaner and more lightweight code. For instance, when crawling a badly coded page with lots of line styles and JavaScript (E.g. content not useful to a spider) the spider may become full too quickly and leave &#8211; missing you important content contained further on within the page.</p>
<p>Validating your site to at least xHTML Transaitional 1.0 (the test strict version, compared to xHTMl 1.0 Strict) is highly encouraged and is an area often ignored by developers. Below, I&#8217;ll quickly outline some of the common validation errors and how to easily fix them:</p>
<p><strong>cannot generate system identifier for general entity X </strong>- 99% of the time this relates to errors with entity references such as ampersands in URLs. E.g. having an url like product.php?id=2&amp;mode=view would result in this error as the &#8216;&amp;&#8217; wasn;t used within the url.</p>
<p><strong>required attribute “alt” not specified</strong> –  simply find the line number and add an alt tag for the image. The presence of an alt tag is required for both transitional and strict doc types.</p>
<p><strong>XML Parsing Error: Opening and ending tag mismatch</strong> &#8211; Depending on how organised you are when coding this fix can take a matter of seconds or a lot longer. It relates to unclosed block level tags, such as a table or div. One plus point is that fixing such an error often results in several validation errors being fixed at once.</p>
<p><span id="more-79"></span></p>
<p><strong>required attribute “TYPE” not specified</strong> &#8211; This relates to no type attribute being specified for things like script and style tags. Solution &#8211; use the type tag like this: <span lang="EN-GB">&lt;script type=”text/javascript” language=”javascript” src=”scripts.js”&gt;</span></p>
<p><strong>There is no attribute “HEIGHT” </strong>- xHTML does not allow for the presence of the height attributer. To resolve, add an inline style or better, specify the height within the css rule for that element.</p>
<p><strong>NET-enabling start-tag requires SHORTTAG YES </strong>or <strong>document type does not allow element “META” here &#8211; </strong>caused by incorrect use of short tags for the page&#8217;s doctype. For example if you have specified an HTML doctype then you use use &lt;br&gt; instead of &lt;br /&gt;.</p>
<p><strong>ID &#8216;someDivname&#8217; already defined &#8211; </strong>caused when you have used two dividers on the same page, with the same id. Solution, uses div class instead of div id if you need multiple dividers on one page.</p>
<p><strong>Missing a required sub element of HEAD </strong>- almost definately caused by missing xHTML required tags from the head section. E.g. have you included a title tag (required in <em>all </em>HTML documents.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/79/fixing-common-w3c-validation-errors-for-seo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
