Professional Web Applications Themes

Creating Dynamic URLs with variable prefixes. - Coldfusion - Advanced Techniques

Hey everyone, I have a PHP script that goes through and checks the prefix on a url and rewrites all of the links in that page accordingly. This is the script: <? if( isset ( $domainArray ) ) { if($domainArray[0] == 'new' ) { $directory = " new.sample.com" } else if .... else ... }[ I need to rewrite that script in coldfusion but I don't know how to replace the '$domainArray[]' variable. Does anyone know a variable I can use or a way I can just read the first three charachters of a url? I thought about using trim. ...

  1. #1

    Default Creating Dynamic URLs with variable prefixes.

    Hey everyone,
    I have a PHP script that goes through and checks the prefix on a url and
    rewrites all of the links in that page accordingly. This is the script:

    <? if( isset ( $domainArray ) )
    {
    if($domainArray[0] == 'new' )
    {
    $directory = " new.sample.com"
    }
    else if ....
    else ...
    }[

    I need to rewrite that script in coldfusion but I don't know how to replace
    the '$domainArray[]' variable. Does anyone know a variable I can use or a way I
    can just read the first three charachters of a url? I thought about using trim.
    Would that work?


    noah Guest

  2. #2

    Default Re: Creating Dynamic URLs with variable prefixes.

    Use the Left( ) function to read the first 3 characters of a string (see below). Trim( ) will remove leading and trailing blanks from a string.

    <CFSET foo = Left(myUrl, 3)>
    jdeline Guest

  3. #3

    Default Re: Creating Dynamic URLs with variable prefixes.

    It looks like domainArray is the domain, split using the .

    ie for a domain of www.sample.com:
    domainArray[0] = www
    domainArray[1] = sample
    domainArray[2] = com

    To do this, just use the ListToArray function, passing it the domain and a
    period as the delimiter:

    <cfset domainArray = ListToArray(domain,".")>

    Kronin555 Guest

  4. #4

    Default Re: Creating Dynamic URLs with variable prefixes.

    Cool, thanks both of you. I did end up finding the script that our company was using to do this. Both of your methods seem simpler though. Thank you.
    noah Guest

Similar Threads

  1. Newbiew--Getting Dynamic Strings to pass as urls
    By FusionRed in forum Macromedia ColdFusion
    Replies: 4
    Last Post: May 28th, 12:26 AM
  2. Making XMLConnector URLs dynamic
    By vandenI3urg in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: March 21st, 06:20 PM
  3. Creating web links from URLs in text
    By Marlene_Hochberg@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 8
    Last Post: May 4th, 05:39 PM
  4. dynamic URLS convert to static URLS for search engines
    By Steve T. in forum ASP.NET Web Services
    Replies: 7
    Last Post: March 4th, 03:16 PM
  5. Creating Clean URLs
    By Creative Acceleration in forum ASP
    Replies: 7
    Last Post: August 4th, 08:09 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139