Reply to topic
Strange CFLOCATION behavior.
DonR


Joined: 25 Oct 2007
Posts: 4
Reply with quote
Hi All,

I'm trying to use the domain name redirect to use subdirectories for other domain names.
I'm getting a response I did not expect from CFLOCATION.

Here's the code in my application.cfc in the onRequestStart function:
Code:

<!--- Redirect to "Sites" --->
<cfswitch expression="#CGI.Server_Name#">
   <cfcase value="www.dailyviewoftheword.com,dailyviewoftheword.com" delimiters=",">
       <cflocation url="dv" addtoken="no">
        <cfabort>
    </cfcase>
    <cfdefaultcase>
    </cfdefaultcase>
</cfswitch>


"dv" is the name of the root directory for that site. I am expecting to get simply http://www.dailyviewoftheword.com for my url, but I am getting: http://www.dailyviewoftheword.com/dv/dv

Am I missing something obvious, or is it just not obvious?

Thanks,
Don
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1029
Location: Felton, Delaware
Reply with quote
I'm not sure if the CFABORT is throwing things off somehow as it's not necessary, but I removed the defaultcase, too, as it's redundant as well.

Other than THAT, and I'm thinking that this is what your problem REALLY is, it seems that your onRequestStart function may be getting called twice. Make sure it doesn't get called again after the first run thru. Maybe use the slash (as I've provided below). I'm not entirely sure how to get around that part of the proposed problem, but I'm thinking that the redirect is running twice.

Code:
<!--- Redirect to "Sites" --->
<cfswitch expression="#CGI.Server_Name#">
   <cfcase value="www.dailyviewoftheword.com,dailyviewoftheword.com" delimiters=",">
       <cflocation url="/dv" addtoken="no" />
    </cfcase>
</cfswitch>


Good luck, and let us know!
DonR


Joined: 25 Oct 2007
Posts: 4
Reply with quote
Thanks for the assistance.

Well, that didn't work. I got a response of "Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

Although the resulting URL is: http://www.dailyviewoftheword.com/dv/

It would be nice to be able to map the domain name to the directory. I've seen other code on the forum that uses the include tag, but that seems problematic to me.

Could it be a problem with how the DNS zone was setup?
Maybe I should ask tech support?

Thanks,
Don
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1029
Location: Felton, Delaware
Reply with quote
DonR wrote:
"Firefox has detected that the server is redirecting the request for this address in a way that will never complete."


Okay that answered my initial question. Your redirect script is being called at www.dailyviewoftheword.com AND www.dailyviewoftheword.com/dv/ AND www.dailyviewoftheword.com/dv/dv etc...

You need to check to see if you're already in the /dv folder, and if so, not perform the redirect.
DonR


Joined: 25 Oct 2007
Posts: 4
Reply with quote
Sounds logical.

So, I should do something like this...

If "/dv" is not in the path, redirect;
otherwise do nothing.

Should I us the FindNoCase function for this, or is there a better option?

I will setup a case in the switch for each "site" or subdomain I have, right?

Thanks,
Don
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1029
Location: Felton, Delaware
Reply with quote
You'll want to...

1) check to see if /dv exists in the URL.
2) make sure it only exists once.
3) that it exists, only once, directly behind the domain

Then, assuming that it IS in the URL and that it only exists once directly behind the domain, don't execute that chunk again.

Now that's a bandaid for a problem. The better solution is to figure out why it's executing twice and stop it from doing so.

Good Luck!
DonR


Joined: 25 Oct 2007
Posts: 4
Reply with quote
I think it's executing twice because I have it in OnRequestStart in my application.cfc.

Where should it be, if not there?

Thanks,
Don
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1029
Location: Felton, Delaware
Reply with quote
There is an easy way to tell when OnRequestStart is firing... create a log.

Before your redirection portion, have a chunk of code that reports the current FULL URL, date/time, and anything else you think will be useful to the file. That will tell you WHEN and WHERE it's firing.
Strange CFLOCATION behavior.
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic