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

'&' and '?' in a URL

New Here ,
Sep 15, 2010 Sep 15, 2010

How to use '&' and '?' in a URL?

May I do

<cfset str = str & "&lang=fr">

and

<cfset path = "http://" & servername & "/" & path & "?" & str>

as in the following code:

<cfset servername = #cgi.SERVER_NAME#>

<cfset script = #cgi.SCRIPT_NAME#>

<cfset str = #cgi.query_string#>

<cfif find("lang=en", str)>

      <cfset str = ReplaceNoCase(str, "lang=en", "lang=fr")>

<cfelse>

     <cfset str = str & "&lang=fr">

</cfif>

<cfset position = find("TEST", script)>

<cfset length = Len(script)>

<cfset path = Mid(script, position, length)>

<cfset path = "http://" & servername & "/" & path & "?" & str>

<li><div><a href="<cfoutput>#path#</cfoutput>">Fran&ccedil;ais</a></div></li>

TOPICS
Getting started
476
Translate
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
LEGEND ,
Sep 15, 2010 Sep 15, 2010
LATEST

You appear to already know how to use ampersands and question marks in a url.  For the rest of it, if you are not achieving the desired result, look at your variables.  In other words, output early and output often.  Once what you see is different than what you expect, you'll know what to fix.

Translate
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