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

Adding a Missing & in a URL

New Here ,
May 15, 2012 May 15, 2012

I have some URLs with missing &s between variables in the query string.  I've fixed the issue that created these bad links, but a bunch of the pages are still in the search engines.  I would like to setup a 301 for these so that they end up going to the right place, but none of the things that I've tried works.   I've tried all of the options below (both with [0-9]+ and with a specific number) and nothing seems to work.  Any suggestions? 

I need them to use the [0-9]+ because this is just an example of the issue... there are lots of numbers involved and several different surrounding variables.

<cfif find("[0-9]+reports",cgi.script_name)>

<cfset errorstring = reReplaceNoCase(cgi.query_string, "[0-9]+reports", "&reports")>

<cfoutput>

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

<cfheader name="Location" value="#cgi.script_name#?#errorstring#">

<cfabort>

</cfoutput>

</cfif>

<cfif isDefined("[0-9]+reports")>

<cfset errorstring = reReplaceNoCase(cgi.query_string, "[0-9]+reports", "&reports")>

<cfoutput>

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

<cfheader name="Location" value="#cgi.script_name#?#errorstring#">

<cfabort>

</cfoutput>

</cfif>

<cfif StructKeyExists(url,'2reports')>

<cfset errorstring = reReplaceNoCase(cgi.query_string, "2reports", "&reports")>

<cfoutput>

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

<cfheader name="Location" value="#cgi.script_name#?#errorstring#">

<cfabort>

</cfoutput>

</cfif>

345
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
New Here ,
May 15, 2012 May 15, 2012
LATEST

I should have writting:

<cfif find("2reports",cgi.query_string)>

<cfset errorstring = reReplaceNoCase(cgi.query_string, "2reports", "&reports")>

<cfoutput>

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

<cfheader name="Location" value="#cgi.script_name#?#errorstring#">

<cfabort>

</cfoutput>

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