Jump to content

Re-direct user based on what url is


slyte33

Recommended Posts

What I want to do is re-direct a user if their url on my site isn't "enter url here"

 

I want to do this because the whole page is an iframe and i don't want them to be able to leave the iframe.

 

I'm pretty unsure on how to do this, so help would be greatly appeciated :)

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/193410-re-direct-user-based-on-what-url-is/
Share on other sites

	$url_parts = parse_url($_SERVER['REQUEST_URI']);
if($url_parts['path'] != '/somepage.php') {
	header('Location: /somepage.php');
	exit();
}

Or you could do a RewriteRule in the .htaccess file and have apache do it

 

When I try to do this, it tells me:

 

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

 

Heres what I put:

 

$url_parts = parse_url($_SERVER['REQUEST_URI']);

 

 

 

if($url_parts['path'] != 'logged_in.php') {

 

 

 

header('Location: index.php');

 

 

 

 

 

exit();

 

 

}

 

var_dump the $_SERVER superglobal and also $url_parts to make sure they're what you expect.

var_dump($_SERVER);
$url_parts = parse_url($_SERVER['REQUEST_URI']);
var_dump($url_parts);
if($url_parts['path'] != 'somepage.php') {
//	header('Location: somepage.php');
//	exit();
}

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.