Jump to content


make file readable only when it is included or required else display error404

display url 404 error404 url

  • Please log in to reply
1 reply to this topic

#1 Regex

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 19 May 2013 - 05:59 PM

I how a problem that if someone goes in myurl.../content.php he can see my content.php file but I would like that it could bee seen only  when I include that in myurl.../index.php. How it could be done that if someone goes to myurl.../index.php/content.php he is redirected to error 404 but if I include that file somewhere then it does not redirecting.



#2 kicken

  • Gurus
  • Wiser? Not exactly.
  • 3,289 posts
  • LocationBonita, FL

Posted 19 May 2013 - 06:24 PM

Have index.php define a constant, and inside content.php check if that constant has been defined. Of not, redirect.

define('IN_INDEX_PHP', true);
if (!defined('IN_INDEX_PHP')){
   header('Location: index.php');

Recycle your old CD's, don't trash them!
Did I help you out? Feeling generous? I accept tips via Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users