WebFaction
Community site: login faq

I've often heard that it's good practice to keep PHP files out of the web directory as much as possible (especially those containing sensitive info), just to be double-sure they can never be served accidentally as static files, even if some accidental future change means that Apache fails to execute them as PHP when requested.

My web applications all live in one directory, so I'm not sure what the best approach is – it seems a bit messy to have a whole bunch of *_php folders in the same place as all my web application folders. Is there any recommended practice for how to get your PHP code out of the web directory on WebFaction?

asked 26 May '12, 08:01

callum
324
accept rate: 0%


Hi,

If you are developing the application yourself, you can have only the index.php file in the app directory, and use include() in it to include everything else from a directory below that level.

permanent link

answered 26 May '12, 08:15

todork
1.2k5
accept rate: 34%

Hi, thanks for your answer. I know I can use require() so I can store files in the parent directory of my application, but the problem is: that parent directory is also the parent directory of all my other web applications. I can't store the application code of multiple websites in the same folder. Is there a way to make it so the web root is a folder called 'public' or similar inside my application folder, as opposed to the application folder itself?

(02 Jun '12, 15:37) callum

You can store the application code in it's own directory attached to your user $HOME/application_code for instance. That way it will be separate from your other applications.

(02 Jun '12, 15:55) aaront ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×57
×19

question asked: 26 May '12, 08:01

question was seen: 4,148 times

last updated: 02 Jun '12, 15:55

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM