On Thu, Jun 3, 2010 at 11:06 AM, Che Vilnonis <ch...@asitv.com> wrote:
> > Here is the scenario. I own a domain. Call it domain.com. I also own an > often misspelled version, domains.com. Note the extra 's'. > I'd like to have domain.com automatically redirect to www.domain.com. > I'd also like have the www.domains.com or domains.com automatically > redirect > to www.domain.com. > I'm using IIS6. > > Anyway, I'm using the following code in onSessionStart: > > <!--- domain redirects. ---> > <cfif cgi.server_name eq "http://domain.com" or cgi.server_name contains > "domains.com"> > <cfheader statuscode="301" statustext="Moved permanently"> > <cfheader name="Location" value="http://www.domain.com"> > </cfif> > > It seems to work. But I have a few questions. > > 1. Is onSessionStart the best place to put this code? > 2. Should I be doing this type of redirect in IIS 6 instead of CF? If so, > how? > 3. Are the any search engine related "penalties" to doing any of these > redirects? > > Thanks, Che > > > here is what I use in OnRequestStart <!--- 301 REDIRECTION TO THE CORRECT DOMAIN NAME - So that all requests include the www ---> <cfset sDefaultDomain = "www.TheDomainNameYouWant.com"> <!--- Domain Name - Do NOT include the www ---> <cfset sDefaultPage = "index.cfm"> <!--- Default page index.cfm, default.cfm etc ---> <cfif NOT #CGI.SERVER_NAME# IS "www.#sDefaultDomain#"> <CFHEADER STATUSCODE="301" STATUSTEXT="Moved permanently"> <CFIF Right(CGI.SCRIPT_NAME,Len(sDefaultPage )) IS sDefaultPage > <CFSET strNewURL=" http://www.#sDefaultDomain##ReplaceNoCase(CGI.SCRIPT_NAME,sDefaultPage, "")#"> <CFELSE> <CFSET strNewURL=" http://www.#sDefaultDomain##CGI.SCRIPT_NAME#"> </CFIF> <CFIF #CGI.QUERY_STRING# NEQ ""> <CFSET strNewURL="#strNewURL#?#CGI.QUERY_STRING#"> </CFIF> <CFHEADER NAME="Location" VALUE="#strNewURL#"> </cfif> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334260 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm