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

Access files outside of web root?

LEGEND ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Hello, everyone.

Hypothetical scenario.

Say I wanted to have a file that would set globally accessible variables for containing passwords, and I want to place said file outside of web root, so users cannot access it.

Logical paths obviously won't work.  And the cfinclude tag doesn't use physical paths.

I've never done this, before.  What are my options?

Thank you,

^_^

Views

1.9K

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Sep 21, 2012 Sep 21, 2012

Almost all your CFML files should not be in a web-browseable directory!  Only the ones people actually browse to should be web accessible.

Files do not need to be web accessible to be <cfinclude>-ed or be instantiated as objects, or used as a custom tag.

EG:

C:\webapps\myapp <= this dir is the root as far as ColdFusion is concerned

C:\webapps\myapp\wwwroot <= that dir is the webroot as far as the web server goes

C:\webapps\myapp\includes <= files you <cfinclude>

C:\webapps\myapp\api <= CFCs

The only st

...

Votes

Translate

Translate
LEGEND ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Almost all your CFML files should not be in a web-browseable directory!  Only the ones people actually browse to should be web accessible.

Files do not need to be web accessible to be <cfinclude>-ed or be instantiated as objects, or used as a custom tag.

EG:

C:\webapps\myapp <= this dir is the root as far as ColdFusion is concerned

C:\webapps\myapp\wwwroot <= that dir is the webroot as far as the web server goes

C:\webapps\myapp\includes <= files you <cfinclude>

C:\webapps\myapp\api <= CFCs

The only stuff that should be in that wwwroot dir is files people actually browse to (index.cfm, etc), and asset files like images, JS and CSS which need to be served to the browser.

The bulk of your CFM files should be in a subdir of C:\webapps\myapp.

So index.cfm needs to be browseable, and it needs to use the data in secretSecureStuff.cfm which is in the includes dir.  So index.cfm just has:

include "/myapp/includes/secretSecureStuff.cfm";

If the file to be included isn't in the myapp subdir structure for whatever reason, then you can create a mapping in CFAdmin or Application.cfc to point to it, eg:

/external => C:\stuff\somewhere\else

And you'd reference C:\stuff\somewhere\else\outside.cfm via:

include "/external/outside.cfm";

--

Adam

Votes

Translate

Translate

Report

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 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Thanks, Adam.  I have very little experience with CF Admin, but I think I can muddle through setting up a mapping for includes.

^_^

Votes

Translate

Translate

Report

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 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Thanks, Adam.  I have very little experience with CF Admin, but I think I can muddle through setting up a mapping for includes.

Well don't forget you can do your mappings in Application.cfc too.

But, that said, you should be up to speed with CFAdmin, so it looks like here's an opportunity to start lookin'! 😉

Obviously sing-out if you get stuck (that'd be a different thread though, yeah?)

--

Adam

Votes

Translate

Translate

Report

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 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Okay.. starting another thread. 

Votes

Translate

Translate

Report

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 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Custom tags and cfc's can be set up outside the webroot.  You have to specify the location in CF Admin.

Votes

Translate

Translate

Report

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
Advocate ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

LATEST

Dan Bracuk wrote:

Custom tags and cfc's can be set up outside the webroot.  You have to specify the location in CF Admin.

Or in Application.cfc.

Everything that Adam already said.

jason

Votes

Translate

Translate

Report

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
Documentation