Skip to main content
September 12, 2014
Answered

How to redirect on htttp to https with www redirect of coldfusion mx7?

  • September 12, 2014
  • 1 reply
  • 10811 views

Hi any one help me  - How to redirect on htttp to https with www redirect of coldfusion mx7?

    This topic has been closed for replies.
    Correct answer

    You should run the following code, and convince yourself that the URLs are accessible, by opening each in a browser:

    <cfoutput>

    https://www.site.com#CGI.SCRIPT_NAME# <br>

    https://#CGI.SERVER_NAME##CGI.SCRIPT_NAME# <br>

    http://www.site.com#CGI.SCRIPT_NAME#

    </cfoutput>


    I used below code. its working perfectly. thanks a lot. 

    <cfif (CGI.SERVER_NAME EQ "site.com") and (CGI.https NEQ "on")>

    <cfheader statuscode="301" statustext="Moved permanently">

    <cfheader name="Location" value="https://www.site.com#CGI.SCRIPT_NAME#">

    </cfif>

    <cfif (CGI.SERVER_NAME EQ "www.site.com") and (CGI.https NEQ "on")>

    <cfheader statuscode="301" statustext="Moved permanently">

    <cfheader name="Location" value="https://www.site.com#CGI.SCRIPT_NAME#">

    </cfif>

    <cfif CGI.SERVER_NAME EQ "site.com">

    <cfheader statuscode="301" statustext="Moved permanently">

    <cfheader name="Location" value="http://www.site.com#CGI.SCRIPT_NAME#">

    </cfif>

    1 reply

    BKBK
    Adobe Expert
    September 12, 2014

    To redirect as you describe is a matter for the web server. The settings will therefore depend on whether you use Apache, IIS or Coldfusion's built-in JRun.

    September 12, 2014

    Thanks...

    below code i have used but it returns status is 302 redirect. need code for 301 redirect?

    <cfif (CGI.SERVER_NAME EQ "site.com") and (CGI.https NEQ "on")>

    <cflocation addtoken="no" url="https://www.site.com#CGI.SCRIPT_NAME#">

    </cfif>

    <cfif (CGI.SERVER_NAME EQ "www.site.com") and (CGI.https NEQ "on")>

    <cflocation addtoken="no" url="https://#CGI.SERVER_NAME##CGI.SCRIPT_NAME#">

    </cfif>

    <cfif CGI.SERVER_NAME EQ "site.com">

        <cflocation addtoken="no" url="http://www.site.com#CGI.SCRIPT_NAME#">

    </cfif>

    September 15, 2014

    You should run the following code, and convince yourself that the URLs are accessible, by opening each in a browser:

    <cfoutput>

    https://www.site.com#CGI.SCRIPT_NAME# <br>

    https://#CGI.SERVER_NAME##CGI.SCRIPT_NAME# <br>

    http://www.site.com#CGI.SCRIPT_NAME#

    </cfoutput>


    Hi BKBK,


    Thanks for your code. its perfectly working. thanks a lot. one more doubt. i need how to move image path 301 redirect for http to https  in our whole sites coldfusion mx7?