{RESOLVED} Force Start Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tmaiden
Forum Commoner
Posts: 64
Joined: Fri Feb 24, 2006 3:15 pm
Location: Philadelphia
Contact:

{RESOLVED} Force Start Page

Post by tmaiden »

I want to force users to goto my main page (http://www.mysite.com/index.php)

If the user is outside of my page, ex: google.com

I don't want them to be able to type http://www.mysite.com/index.php?q=1 and goto q=1
instead if they type http://www.mysite.com/index.php?q=1 i want them to be redirected to http://www.mysite.com

once they have visted the main page, http://www.mysite.com, then they can follow links to index.php?q=1

Any suggestions or code snippets would greatly be appriciated.

Thanks.
User avatar
tmaiden
Forum Commoner
Posts: 64
Joined: Fri Feb 24, 2006 3:15 pm
Location: Philadelphia
Contact:

Post by tmaiden »

Code: Select all

$domains="www.mysite.com,mysite.com"; 

$domains=explode(",",$domains);   

if($_GET['q']!="")   { 
  
     $referer=explode("/",($_SERVER['HTTP_REFERER']));

     if(!in_array($referer[2],$domains))     {

          header("Location: http://".$domains[0]."/");     

          exit();     

     }  
 
}
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

That's a very bad idea since the HTTP_REFERER may not always exist.
Post Reply