Jump to content

force php pages not to load


nitation

Recommended Posts

Hello. I have a page named foo.php, how do i force the page not to display when a user type it directly to the browser.

 

scenario:

 

when a user type http://www.mydomain.com/foo.php

 

i want it to redirect the user to http://www.mydomain.com/index.php

 

Please note: That is only when they type it. Somewhere in my code, i will still make use of foo.php

I guess what am looking for is not just a header redirect.

 

header("Location:some_link.php");

exit;

 

Link to comment
https://forums.phpfreaks.com/topic/139971-force-php-pages-not-to-load/
Share on other sites

Use some form of redirect.

 

To make it accept it for PHP-include just set a variable like $dummy. and then test with foo.php

 

if (!isset($dummy)) {
redirect
}

 

That way, $dummy will only be set when you PHP-include or whatever.  If you are putting it in an iFrame you could have it try this.

 

<script type='text/javascript'>
if (parent.location == window.location) {
parent.location = "http://www.website.com/index.php";
}
</script>

 

But that will only work with Javascript-enabled browsers.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.