|
[x]
Posted via EE Mobile
|
|
| Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
|
|
|
|
Asked by mcerabona in CGI Scripting, Web Languages/Standards, Cold Fusion Markup Language
I am trying to create a redirect based on the url that someone comes from. So for example, if
www.mydomain.com they get the index file, but if they come into
www.mydomain.com/marc. they are redirected to a specific url. I have a table and code that pulls up the redirect, but when I put it into the application file it does not work. In the code below I end up with the index file working fine but if I use the /marc it drops out. I have tried this using both cflocation and cfheader.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
|
<cffunction name="getWebPath" access="public" output="false" returntype="string" hint="Gets the absolute path to the current web folder.">
<cfargument name="url" required="false" default="#getPageContext().getRequest().getRequestURI()#" hint="Defaults to the current path_info" />
<cfargument name="ext" required="false" default="\.(cfml?.*|html?.*|[^.]+)" hint="Define the regex to find the extension. The default will work in most cases, unless you have really funky urls like: /folder/file.cfm/extra.path/info" />
<!---// trim the path to be safe //--->
<cfset var sPath = trim(arguments.url) />
<!---// find the where the filename starts (should be the last wherever the last period (".") is) //--->
<cfset var sEndDir = reFind("/[^/]+#arguments.ext#$", sPath) />
<cfreturn left(sPath, sEndDir) />
</cffunction>
<cfset getwebpath = getWebPath()>
<cfset getwebpathfixed = REREPlace(#getwebpath#, "[[:punct:]]", "", "ALL")>
<cfoutput> -#getwebpathfixed#- - #getwebpath# </cfoutput>
<cfif len(#getwebpathfixed#) is not 0 >
<cfquery name="geturls" datasource="#dbLoc#">
SELECT `urlredirect` , `urloriginal` , `urlid`
FROM `tblurlredirect`
where urloriginal like '#getwebpathfixed#'
LIMIT 0 , 30
</cfquery>
<cflocation url="#geturls.urlredirect#">---><cfoutput>#geturls.urlredirect# </cfoutput>
</cfif>
|
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625