Blog of an Open Mind

Open Minded Thinking from the Open Minded Solutions team…

Blog of an Open Mind header image 2

ColdFusion and IsapiRewrite Gubbins…

April 14th, 2009 · No Comments

Had a minor issue today from a client using Open Mind Commerce that took a bit of time to track down and solve but the solution was quite simple so I thought I would share…

Open Mind Commerce uses ISAPI Rewrite to produce search engine sexy (I don’t like the word safe) URLs so www.domain.com/store/d1-my-department/ is rewritten server side so the template actually executes www.domain.com/store.cfm?deptid=1

Now this works great until the client changes the URL structure in their settings which although a great feature for setting the actual URL can lead to duplicate content in the SEs.

I had to find a way to look at the URL before it was rewritten, compare this to the real URL in the database and then redirect if it was different.

Enter CGI.HTTP_X_REWRITE_URL

This variable supplies you with the raw URL before it is rewritten server side, bonza! So pseudo code time…

<cfif cgi.HTTP_X_REWRITE_URL NEQ "my stored URL">
<cfheader statuscode="301" statustext="Moved permanently">
</cfheader>
<cfheader name="Location" value="http://www.new-url-indatabase.com">
</cfheader>
</cfif>

All we are doing here is comparing the incoming rewritten url with the one that should be in use (from our database) and then using the cfheader command to do a 301 redirect. The result? No more dupes…

Tags: Tinterweb stuff

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.