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

Community Beginner ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

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

Views

8.4K

Likes

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

correct answers 1 Correct Answer

Community Beginner , Sep 14, 2014 Sep 14, 2014
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"><...

Likes

Translate

Translate
Adobe Community Professional ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

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.

Likes

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
Community Beginner ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

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>

Likes

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
Adobe Community Professional ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

In pre-Coldfusion 8, you could use the combination

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

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

in place of

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

Likes

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
Community Beginner ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

Hi thanks for your code..

i have used your code  is lines but below error is mentioned...

The page isn't redirecting properly

Likes

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
Community Beginner ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

  In this code also i used  but its return 302 redirect.

<!--- Change http to https --->
<cfif IsDefined("CGI.HTTPS")> <!--- Make sure the variable exists --->
<cfif CGI.HTTPS EQ "off" OR CGI.HTTPS IS ""> <!--- Test for a blank value --->
<cflocation addtoken="no" url="https://#CGI.SERVER_NAME##CGI.SCRIPT_NAME#">
</cfif>
</cfif>

Likes

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
Community Beginner ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

any code for  redirect 301 ( http to https coldfusion mx7) for access all site?

Likes

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
Adobe Community Professional ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

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>

Likes

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
Community Beginner ,
Sep 14, 2014 Sep 14, 2014

Copy link to clipboard

Copied

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?



Likes

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
Adobe Community Professional ,
Sep 15, 2014 Sep 15, 2014

Copy link to clipboard

Copied

LATEST

maniseo wrote:

one more doubt. i need how to move image path 301 redirect for http to https  in our whole sites coldfusion mx7?

I do not quite understand. Do you wish to redirect an image path from HTTP to HTTPS? If so, you could set this up in the web server. What web server do you use?

Likes

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
Community Beginner ,
Sep 14, 2014 Sep 14, 2014

Copy link to clipboard

Copied

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>

Likes

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
Adobe Community Professional ,
Sep 15, 2014 Sep 15, 2014

Copy link to clipboard

Copied

Thanks a lot for sharing that. To help others, please mark it as the correct answer.

Likes

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
Adobe Community Professional ,
Sep 12, 2014 Sep 12, 2014

Copy link to clipboard

Copied

maniseo wrote:

i have used your code  is lines but below error is mentioned...

The page isn't redirecting properly

It is unclear to me what you mean. The cfheader code runs just fine when I test it with

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

<cfheader name="Location" value="https://wikidocs.adobe.com/wiki/display/coldfusionen/home">

What happened when you ran the code? Did Coldfusion show you an error message?

Likes

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