Highlighted

Redirecting index.cfm to dynamic.cfm without parameters :(

New Here ,
Apr 23, 2015

Copy link to clipboard

Copied

Hello Everyone, I have this code that works great, but there is one little problem.

When user inputs index.cfm it does not forward to plain dynamic.cfm

So it seems to me that i need to modify this code so it can handle at least one more option

The script works very well when user inputs index.cfm?myID=#url.myID then redirects to dynamic.cfm?myID=#url.myID

How could I make it work? Any help greatly appreciated

<!-- File name: index.cfm -->

<cfoutput>

<cfif isDefined("url.myID") AND IsNumeric(url.myID) AND url.myID NEQ 0>    

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

<cfheader name="Location" value="dynamic.cfm?myID=#url.myID#">

</cfif>

</cfoutput>

<cfabort>

You will need to add an "else" clause to your "if" statement. All you are doing is checking for the "myID" parameter and doing nothing if it doesnt exist.

I assume you wont something like this:

<cfoutput>

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

    <cfif isDefined("url.myID") AND IsNumeric(url.myID) AND url.myID NEQ 0>     

          <cfheader name="Location" value="dynamic.cfm?myID=#url.myID#">

    <cfelse>

          <cfheader name="Location" value="dynamic.cfm">

    </cfif>

</cfoutput>

<cfabort>

Views

277

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

Redirecting index.cfm to dynamic.cfm without parameters :(

New Here ,
Apr 23, 2015

Copy link to clipboard

Copied

Hello Everyone, I have this code that works great, but there is one little problem.

When user inputs index.cfm it does not forward to plain dynamic.cfm

So it seems to me that i need to modify this code so it can handle at least one more option

The script works very well when user inputs index.cfm?myID=#url.myID then redirects to dynamic.cfm?myID=#url.myID

How could I make it work? Any help greatly appreciated

<!-- File name: index.cfm -->

<cfoutput>

<cfif isDefined("url.myID") AND IsNumeric(url.myID) AND url.myID NEQ 0>    

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

<cfheader name="Location" value="dynamic.cfm?myID=#url.myID#">

</cfif>

</cfoutput>

<cfabort>

You will need to add an "else" clause to your "if" statement. All you are doing is checking for the "myID" parameter and doing nothing if it doesnt exist.

I assume you wont something like this:

<cfoutput>

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

    <cfif isDefined("url.myID") AND IsNumeric(url.myID) AND url.myID NEQ 0>     

          <cfheader name="Location" value="dynamic.cfm?myID=#url.myID#">

    <cfelse>

          <cfheader name="Location" value="dynamic.cfm">

    </cfif>

</cfoutput>

<cfabort>

Views

278

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
Apr 23, 2015 0
Advocate ,
Apr 24, 2015

Copy link to clipboard

Copied

You will need to add an "else" clause to your "if" statement. All you are doing is checking for the "myID" parameter and doing nothing if it doesnt exist.

I assume you wont something like this:

<cfoutput>

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

    <cfif isDefined("url.myID") AND IsNumeric(url.myID) AND url.myID NEQ 0>     

          <cfheader name="Location" value="dynamic.cfm?myID=#url.myID#">

    <cfelse>

          <cfheader name="Location" value="dynamic.cfm">

    </cfif>

</cfoutput>

<cfabort>

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
Reply
Loading...
Apr 24, 2015 0
New Here ,
Apr 24, 2015

Copy link to clipboard

Copied

Hello Haxtbh, Yes it does work thank you so much

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
Reply
Loading...
Apr 24, 2015 0