3 Replies Latest reply on Aug 26, 2010 12:02 PM by ilssac

    CF redirect

    Phnoefniex

      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

        • 1. Re: CF redirect
          Dan Bracuk Level 5

          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.

          • 2. Re: CF redirect
            Phnoefniex Level 1

            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

            • 3. Re: CF redirect
              ilssac Level 5

              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.