Supposed the page is example.com/blog/data.php. I am using file_get_contents to get the content in another script page. Now, i want to:
- Forbid google search to crawl and index the data.php page.
- Forbid the visitor to access it
Is there a way to achieve this?
You can redirect to another page if the request url is
example.com/blog/data.php, but a far easier and more logical solution would be to move the file out of your web-root.Edit: If you really want to keep the file inside the web-root, you can use something like this at the top of the script that you don’t want to access directly:
However, this will probably not work in combination with
file_get_contents(you need to remove these lines from the result), you couldincludethe file instead.