• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Apr 23, 2015 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>

Views

482

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

Advocate , Apr 24, 2015 Apr 24, 2015

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">

    </cf

...

Votes

Translate

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

Votes

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
New Here ,
Apr 24, 2015 Apr 24, 2015

Copy link to clipboard

Copied

LATEST

Hello Haxtbh, Yes it does work thank you so much

Votes

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
Resources
Documentation