php : view.php
<h1>hello world</h1>
php: index.php
require('view.php');
if both files are on root mysite.com
if I access mysite.com/index.php I should get ‘hello world‘
if I access mysite.com/view.php I should get Nothing displayed.
I was looking for some .HTACCESS method but any other suggestions are welcomed 🙂
Conclusion: wish the user to not be able to see the view plain text, and only allow the required or get_file_contents() to read the files. So read the file only within server.
The best way to handle this is to have your include files that are never intended to be accessed outside the web root, where they can never be accessed via a browser.
i.e. your file structure would be:
You can set PHP’s
include_pathto include theincludes/directory so your includes don’t need to have a path explicitly in them, too.