ColdFusion redirect – cflocation

Adobe ColdFusion

Adobe ColdFusionI had to change the domain of a longstanding ColdFusion site with hundreds of pages. With .htaccess on an Apache Linux host this is easy and well documented. With ColdFusion on IIS when you are not a full administrator of the IIS server…. not so much.  My searches found post after post with the same instruction, how to redirect an individual page or an entire domain to one single new URL. Whaaatttt!? Why you no care about your customers and visitors!

Adobe cflocation doc – not exactly chocked full of details

Google returns a lot of sites with the simple but not very helpful nuclear option:

<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="http://www.newlocation.com">

Then I found a rare post on Katzwebservices with details on how to redirect a single page, prefix all pages with www or  https and how to properly redirect an entire website:
https://katz.co/coldfusion-redirects/

The Author of the code gives a shout to Ben Nadel and can be found in the comments here:
http://www.bennadel.com/blog/378-Getting-The-Requested-URL-From-The-Page-Request-Object-Servlet-Without-Using-CGI.htm

I used the code there and ended up with the below to redirect all pages from an existing site and forums on domainA to domainB. Google picked it up within 2 days and all pages are now listed with domainB.com. Thank you Ben Zadel and  Zack Katz!

<!--- If site is www.domainA.com --->
<cfif (CGI.SERVER_NAME EQ "www.domainA.com")>
<!--- Save the URL (and $_GET variables too) as the string 'strUrl' --->
<cfset strUrl = CGI.script_name & "?" & CGI.query_string />
<!--- Use 301 for SEO-friendly redirects --->
<cfheader statuscode="301" statustext="Moved permanently">
<!--- Redirect to new website (this case, added www.) with strUrl added on --->
<cfheader name="Location" value="http://www.domainB.com#strUrl#">
</cfif>
<!--- If site is domainA.com --->
<cfif (CGI.SERVER_NAME EQ "domainA.com")>
<cfset strUrl = CGI.script_name & "?" & CGI.query_string />
<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="http://www.domainB.com#strUrl#">
</cfif>

ColdFusion 8 Data Source with MS SQL Express 2005

sql2008

After upgrading my development system from ColdFusion MX and MS SQL 2000 to ColdFusion 8 and MS SQL Express 2005 I was getting the dreaded SQLServer JDBC Driver errors. The fix is in the Adobe link below – custom config the TCP/IP settings. In my case I used the existing “Dynamic port”

Connection verification failed for data source: {data source name}
java.sql.SQLException: [Macromedia][SQLServer JDBC Driver]Error
establishing socket. Connection refused: connect
The root cause was that: java.sql.SQLException: [Macromedia][SQLServer
JDBC Driver] Error establishing socket. Connection refused: connect

http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400255&sliceId=1

SQL 2005 TCP Settings
– Protocols for SQLEXPRESS
– Set “Enabled” to “Yes” For IP1 & IP2
– Note the port for IPALL
SQL Express TCP IP Config

ColdFusion Datasource
– SQL Server Port
ColdFusion 8 Datasource SQL Port SQL 2005