mind-owner Posted December 4, 2007 Share Posted December 4, 2007 How do I make a page redirect to "www.mysite.com" if $_GET['file'] not foundThanksMind-owner Link to comment Share on other sites More sharing options...
Ingolme Posted December 4, 2007 Share Posted December 4, 2007 if(!strlen($_GET['file'])) {header("Location: http://www.mysite.com");} Link to comment Share on other sites More sharing options...
mind-owner Posted December 4, 2007 Author Share Posted December 4, 2007 if(!strlen($_GET['file'])) {header("Location: http://www.mysite.com");}Well it doesn't work"It redirects even if file found"$_GET['file'] is actualy used as a bg in my gd library script so what I want it to do is if bg "$_GET['file']" not found it will redirect Link to comment Share on other sites More sharing options...
Ingolme Posted December 4, 2007 Share Posted December 4, 2007 Do you mean that the file is not found, or that the $_GET variable doesn't exist? Link to comment Share on other sites More sharing options...
mind-owner Posted December 4, 2007 Author Share Posted December 4, 2007 Do you mean that the file is not found, or that the $_GET variable doesn't exist?Well "www.mysite.com/2/text.png"the 2 is the $_GET['file'] which is the bg in my gd library script so if the $_GET['file'] not found it redirects Link to comment Share on other sites More sharing options...
Ingolme Posted December 4, 2007 Share Posted December 4, 2007 I'm not sure what you mean, but if you want to try this:if(!file_exists($_GET['file'])) {header("Location: http://www.mysite.com");} Link to comment Share on other sites More sharing options...
justsomeguy Posted December 4, 2007 Share Posted December 4, 2007 If this is the file you're looking for:/2/text.pngAnd the 2 comes from $_GET['file'], you can check like this:if (!file_exists($_GET['file'] . "/text.png")){header("Location: http://www.mysite.com");}You might also need to use the full path to the file instead of a relative path. So if the script this code is in is in the root of the site then you can use this:if (!file_exists(dirname(__FILE__) . "/" . $_GET['file'] . "/text.png")) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.