If you don’t want users to access some files directly from browser then you can simply use following php script on top of such files.
Let us take one file named MYFILE.PHP as an example, all you have to do is just add the below code on the top of all the script
< ?php
// this is first code block
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME']))
{
// tell people trying to access this file directly goodbye...
exit("This file is restricted from direct access");
}
//Rest of the code in your file comes after this
?>
Hope this one will help.Thanks.
Incoming search terms:
- prevent direct access to php file (8)
- php prevent direct access to file (7)
- php prevent direct file access (6)
- mysql avoid direct (3)
- avoid direct access to a file php (3)
- how to avoid direct access page in php (3)
- fpdf error file is encrypted (2)
- how to avoid direct access of php page (2)
- how to avoid direct access to file php (2)
- prevent direct file access wordpress (2)
- how to prevent direct access to a file through url (2)
- php avoid direct access (2)
- php tutorial direct access (2)
- protect direct access to a file using php (2)
- how to avoid direct access of php files (2)
- ajax prevent php direct file access (2)
- avoid direct access to file PHP (2)
- wordpress prevent direct access to uploads (2)
- php protect your code from direct access (1)
- wordpress prevent direct file access (1)
- prevent direct access to pdf file php (1)
- prevent direct access to pdf files with php (1)
- prevent direct access to pdf in wordpress login area (1)
- wordpress no direct access to files (1)
- wordpress prevent accessing directly from the url (1)
- prevent direct access to php file -include (1)
- prevent direct access to php file via url (1)
- prevent direct access to files wordpress (1)
- wp prevent direct file access to uploads (1)
- php stop script direct access (1)
- php to prevent direct access to a url (1)
- php url prevent javascript (1)
- prevent ajax URL direct access (1)
- prevent direct access to js file php (1)
- prevent direct acces to php files (1)
- prevent direct access ajax file (1)
- prevent direct access to a file with php (1)
- prevent direct access to ajax files (1)
- prevent direct access to php script in wordpress (1)
- prevent direct access to video file php (1)
You will also be interested in ,
- Locking a text file database using php
- FPDF error: Alpha channel not supported error message
- Url rewriting examples using .htaccess
- Import large files in mysql using PhpMyAdmin
- Mysql backup via cron using php and email the file
- Tag cloud using php, mysql and ajax with filter
- Using no-cache for Stop Caching in Firefox and Internet Explorer
- Simple XML Reading Using PHP
- Copy mysql column in varchar to type date
- Hit counter using php

