• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CF redirect

New Here ,
Aug 25, 2010 Aug 25, 2010

Copy link to clipboard

Copied

Hello,

my webserver data are as follows:

ColdFusion 5 (is there a particular hotfix you are looking for)?
Windows Server 2003
IIS 6.1.

I would like to do a redirect.

Specification:

For the URL field:

1. If a user enters XXXX.com the user will be pointed to:
http://XXXX.com/MainPath/Main.html

2. If a user enters www.XXXX.com the user will be pointed to:
http://www.XXXX.com/MainPath/Main.html

3. If a user enters XXXX.com/name1 the user will be pointed to http://XXXX.com/Path1

4. If a user enters XXX.com/name2 the user will be pointed to http://XXXX.com/Path2

5. If a user enters XXX.com/name3 the user will be pointed to http://XXXX.com/Path3

I am using this code:

<!--- Default locations --->

<CFIF server_name IS "www.XXXX.com" OR server_name IS "XXXX.com">

<CFLOCATION url="MainPath/Main.html">

<!---  For XXXX.com/name1 --->

<CFELSEIF CompareNoCase(cgi.server_name, "XXXX.com") EQ 0 AND CompareNoCase(ListGetAt(cgi.path_info, 1, "/"),"name1") EQ 0>

<CFLOCATION url=" http://XXXX.com/Path1">

<!---  For XXXX.com/korrosion point to Io00Korro01.cfm --->

<CFELSEIF CompareNoCase(cgi.server_name, "XXXX.com") EQ 0 AND CompareNoCase(ListGetAt(cgi.path_info, 1, "/")," name2") EQ 0>

<CFLOCATION url=" http://XXXX.com/Path2">

<!---  For XXXX.com/cell point to CellCycle01.cfm ---> 

<CFELSEIF CompareNoCase(cgi.server_name, "XXXX.com") EQ 0 AND CompareNoCase(ListGetAt(cgi.path_info, 1, "/")," name3") EQ 0>

<CFLOCATION url=" http://XXXX.com/Path3">

</CFIF>

Specification 1 and 2 above work well with <!--- Default locations --->

<CFIF server_name IS "www.XXXX.com" OR server_name IS "XXXX.com">

<CFLOCATION url="MainPath/Main.html">

But the rest of the code won't do the desired redirects of specification 3 to 5.

Help would be appreciated.

Phnoefniex

TOPICS
Advanced techniques

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 25, 2010 Aug 25, 2010

Copy link to clipboard

Copied

Comment out the cflocation tags so you can look at your data.  Then do this sort of thing.

<cfif something>

yes

<cfelse>

no

<cfdump var="#the_variables_you_were_looking_at#">

closing tags.

adjusted for your own code of course.

At first glance, it looks like you overengineered the whole thing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2010 Aug 26, 2010

Copy link to clipboard

Copied

Hello,

Not sure how to get <cfdump> to work. So I did a test.

I have default.cfm under the root directory.
It only contains this line:

<cfdump var="#URL#">

If I enter XXXX.com into the browser URL it will just display a blank page. How can I get the dump to display in the browser?

Thanks, Phnoefniex

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 26, 2010 Aug 26, 2010

Copy link to clipboard

Copied

LATEST

Are you sure that default.cfm is automatically servers by your web server.  That file is not a common automatic file.  ColdFusion usually only configures index.cfm to be automatically serverd if no specific file is requested.

Have you tried XXXX.com/default.cfm  do you see the dump display then?  Which, of course, is going to be empty becuase you have no url parameters.  xxxx.com/default.cfm?test=foobar will show some data in the dump.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation