Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
PHP Includes
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- PHP Includes
PHP Includes
03-06-2011 10:30 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
If I understand correctly, the general advice on files containing PHP fragments for inclusion in PHP scripts is to place them somewhere outside of the scope of the web-served directory tree. It looks to me as if the organisation of user areas on the PlusNet ccgi setup precludes that, because everywhere under user control is within the served scope. Is best practice on this platform simply to place them in a folder with browsing turned off and permissions set to prevent execution (600: -rw-------)? I'm not particularly familiar with Linux permissions so I'm not too clear about what allows/denies Apache permission to serve a file (other than, presumably, *.php and other script files would presumably be executed server-side and never have their contents delivered to a browser).
Message 1 of 6
(1,105 Views)
5 REPLIES 5
Re: PHP Includes
03-06-2011 12:05 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
You could put them all in a directory (for example 'includes') and use mod_rewrite to deny access. In your cgi home directory (the one you're in when you FTP in) place a file called .htaccess containing:
This will give a 403 Forbidden error for anything in /includes (e.g. http://ccgi.username.plus.com/includes/foo.php). As the PHP include is internal to PHP it will still be able to include them.
RewriteEngine On
RewriteRule ^/includes/? -
This will give a 403 Forbidden error for anything in /includes (e.g. http://ccgi.username.plus.com/includes/foo.php). As the PHP include is internal to PHP it will still be able to include them.
Message 2 of 6
(419 Views)
Re: PHP Includes
03-06-2011 12:49 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Excellent - thanks Ben.
Message 3 of 6
(419 Views)
Re: PHP Includes
03-06-2011 4:04 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Must be Friday.
No leading slash in .htaccess rewrites, so just:
Gabe
No leading slash in .htaccess rewrites, so just:
RewriteEngine Onin the home directory, or
RewriteRule ^includes/? -
deny from allin the includes directory (or call them foo.inc.php anywhere and use a FilesMatch)
Gabe
Message 4 of 6
(419 Views)
Re: PHP Includes
03-06-2011 4:43 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Gah, I'm more used to writing rewrites in the server config, where you do use a leading slash. Well that's my excuse anyway

Message 5 of 6
(420 Views)
Re: PHP Includes
03-06-2011 4:49 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator

Message 6 of 6
(420 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page