slyte33 Posted February 25, 2010 Share Posted February 25, 2010 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 More sharing options...
F00Baron Posted February 25, 2010 Share Posted February 25, 2010 $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 Link to comment https://forums.phpfreaks.com/topic/193410-re-direct-user-based-on-what-url-is/#findComment-1018285 Share on other sites More sharing options...
slyte33 Posted February 25, 2010 Author Share Posted February 25, 2010 $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(); } Link to comment https://forums.phpfreaks.com/topic/193410-re-direct-user-based-on-what-url-is/#findComment-1018289 Share on other sites More sharing options...
F00Baron Posted February 26, 2010 Share Posted February 26, 2010 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(); } Link to comment https://forums.phpfreaks.com/topic/193410-re-direct-user-based-on-what-url-is/#findComment-1018749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.