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 Quote 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; } ?> Quote 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. Quote 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. Quote 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 ? Quote 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(); } ?> Quote 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; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65528-solved-redirection/#findComment-327220 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.