cheechm Posted August 17, 2007 Share Posted August 17, 2007 Hello, I was wondering if there is a way to redirect someone if the page "isn't the right one". I.e if the page is www.mydomain.com/index.php then the user gets redirected to www.mydomain.com/index.php?pid=0 Thanks Link to comment https://forums.phpfreaks.com/topic/65528-solved-redirection/ Share on other sites More sharing options...
Caesar Posted August 17, 2007 Share Posted August 17, 2007 <?php if(!isset($_GET['pid'])) { header("location: index.php?pid=0"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/65528-solved-redirection/#findComment-327205 Share on other sites More sharing options...
Caesar Posted August 17, 2007 Share Posted August 17, 2007 You can also use a switch, if you want to redirect only for specific instances. Link to comment https://forums.phpfreaks.com/topic/65528-solved-redirection/#findComment-327206 Share on other sites More sharing options...
cheechm Posted August 17, 2007 Author Share Posted August 17, 2007 You can also use a switch, if you want to redirect only for specific instances. I only want to redirect if the URL is www.mydomain.com with no PID. So would the first code be sufficient? Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/65528-solved-redirection/#findComment-327209 Share on other sites More sharing options...
MadTechie Posted August 17, 2007 Share Posted August 17, 2007 I.e if the page is www.mydomain.com/index.php then the user gets redirected to www.mydomain.com/index.php?pid=0 their the same page ? Link to comment https://forums.phpfreaks.com/topic/65528-solved-redirection/#findComment-327217 Share on other sites More sharing options...
phpSensei Posted August 17, 2007 Share Posted August 17, 2007 You Mean <?php if(!isset($_GET['pID'])){ header("Location: www.mydomain.com/index.php"); die(); } ?> Link to comment https://forums.phpfreaks.com/topic/65528-solved-redirection/#findComment-327219 Share on other sites More sharing options...
Caesar Posted August 17, 2007 Share Posted August 17, 2007 I only want to redirect if the URL is www.mydomain.com with no PID. So would the first code be sufficient? Yes, it will. Slight modification.... <?php if((!isset($_GET['pid'])) || ($_GET['pid'] == '') || (!is_numeric($_GET['pid']))) { header("location: index.php?pid=0"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/65528-solved-redirection/#findComment-327220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.