Search code examples
http-redirectcoldfusion

Coldfusion - Redirect website if it hits /folder/index.cfm?


Very new to Coldfusion, but not to web development so hopefully this is an easy question.

We recently changed a link on our website that took us to /folder/index.cfm. I want to make sure that when someone types www.ourwebsite.com/folder that it doesn't take them to /folder/index.cfm and instead to redirect them to another website.

Any pointers?


Solution

  • There are at least three ways it to do this.

    1. Don't even bother with ColdFusion. Have your web server do the redirect. You are going to need to know if it Apache or IIS or whatever. You can then search for how that web server does it.

    This might help you with some of that: Custom 404 error page not working on IIS 8.5

    1. You can make a file at /folder/index.cfm and have a file that has

    OR with cfscript

     <cfscript>
       location("newpage.cfm", false, 301) 
     </cfscript>
    

    Note the addtoken and statuscode are optional. Add token helps because almost no CF website uses this kind of token. The status code helps because tells the browser that this is a permanent move.

    1. You could intercept the request in application.cfc . In fact, in some systems all requested are checked for validity in application.cfc. You might still need a blank page at the target, but at least some ColdFusion is processed

    Of all the options, 1 is my favorite, because there really isn't a lot that can be done with requests to missing pages. And the list of potential missing pages is unlimited.