i am trying to get into js directory which is outs...
# cfml-general
g
i am trying to get into js directory which is outside the admin folder
Copy code
<cfset request.thisUrl = getPageContext().getRequest().GetRequestUrl().toString()>
	<cfset request.websitePath = left(request.thisUrl, len(request.thisUrl) - len(listLast(request.thisUrl,'/')))>
	<cfset request.jsFolder = request.websitePath>
http://localhost:9001/website1/project1/admin/ - this path is the request.websitePath admin Section http://localhost:9001/website1/project1/admin/admin-home.cfm - this is request.thisUrl i am going to go into JS directory like this, how should i get in there http://localhost:9001/website1/js
a
Excellent framing information. What's the question? What do you mean by "get in there?"
I'm tying to work out if a reasonable first observation is "if you want to get to
x
, I wouldn't start from `y`".
So you are on a URL which is formed of three parts basically...
commonPart
,
baseAdminPart
and
requestSpecificAdminPart
. Only
baseAdminPart
and
jsPart
are known (
/project1/admin
and
/js
respectively), the others need to be inferred from the whole URL. And from that you want to derive a URL made from
commonPart
,
jsPart
?
Are you sure you don't know the scheme, host and port (
<http://localhost:9001>
)? Those are all always (?) available in various CGI variables. Do you know even know
website1
? This value doesn't exist anywhere other than in the current URL you need to fetch from the PageContext?
Even if
website1
isn't in some
websiteName
variable or something, is it not simply the first segment of
CGI.script_name
?