Copy link to clipboard
Copied
Hi any one help me - How to redirect on htttp to https with www redirect of coldfusion mx7?
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">
<
...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.
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>
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#">
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
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> |
Copy link to clipboard
Copied
any code for redirect 301 ( http to https coldfusion mx7) for access all site?
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>
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?
Copy link to clipboard
Copied
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?
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>
Copy link to clipboard
Copied
Thanks a lot for sharing that. To help others, please mark it as the correct answer.
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?