I've been tagged [This link opens in a new window]

Search engine safe URLs without mod_rewrite or ISAPI Rewrite

Nowadays it's very important to make your site as search engine friendly as possible, this means not only making your code "acceptable" to search engines, but also ensuring the URLs in your site are tidy and don't contain too much query string data.

So for example, the below would not be ideal:

http://www.domain.com/?id=1&title=mypage

Now with Apache's mod_rewrite or ISAPI Rewrite for IIS you can convert the above to something similar to:

http://www.domain.com/1/mypage/

Not only does the above look much neater, Google will appreciate it more and index it with minimal fuss. Thats all fine and well if you have mod_rewrite/ISAPI Rewrite etc running on your server, what about if you don't?

Well you could make ColdFusion turn all pages into .html files via the <cfhttp> syntax, but that is bulky and not ideal. There is another way however, its not as complete as using mod_rewrite or ISAPI Rewrite, but if its all you have it works fine.

The way to do it is to use SESConverter. Essentially all SESConverter does is replace all query string ?, & and = with a / therefore making the example above look something like:

http://www.domain.com/index.cfm/id/1/title/mypage

It's very easy to implement into your site as well, all you need to do is download the sesconverter.cfm file from the link above, and put this on your server somewhere. Now in your Application.cfm/cfc add the following:

<cfset SESdummyExtension=".cfm">
<cfset SESrBaseName="baseHREF">
<cfinclude template="sesconverter.cfm">

Now this will be called from all your .cfm pages, the final thing to do is to add the <base> tag to your header, so just add the below to the <head> of your document:

<cfif isDefined("variables.baseHref")>
<cfoutput><base href="#variables.baseHref#" /></cfoutput> </cfif>

Now try creating a similar link to the above and it should take you to the same place the "ugly" URL does! Read the SESConverter FAQ for more details.

Currently, to my knowledge this is only available in ColdFusion, but I'm sure there are equivalents for other languages out there.

  • Del.icio.us [This link opens in a new window]
  • Digg [This link opens in a new window]
  • Technorati [This link opens in a new window]
  • Reddit [This link opens in a new window]
  • Stumble Upon [This link opens in a new window]
  • Furl [This link opens in a new window]