rsquaredpgh Posted July 16, 2010 Share Posted July 16, 2010 I'm wondering if there is an easy way to redirect users from a custom url to a specific page. For example, User types in: www.mysite.com/programname and ends up at: www.mysite.com/programs.php?programID=17 Not sure if this specifically falls under PHP but I've gotten help here before and thought I've give it a shot. Thanks in advance for the help. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 16, 2010 Share Posted July 16, 2010 I'm wondering if there is an easy way to redirect users from a custom url to a specific page. For example, User types in: www.mysite.com/programname and ends up at: www.mysite.com/programs.php?programID=17 Not sure if this specifically falls under PHP but I've gotten help here before and thought I've give it a shot. Thanks in advance for the help. If using apache use mod_rewrite, but it would need to be written like this: www.mysite.com/programname - becomes www.mysite.com/programs.php?programID=programname And then in PHP you would need to map the programname to the programID number (normally from a database). Or you could use this: www.mysite.com/programname/15 - becomes www.mysite.com/programs.php?programID=15 Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted July 16, 2010 Share Posted July 16, 2010 You could also just request a dynamic page and if it's blank then just load the main content... thus everytime they type the main address it reroutes them to the new page. // Check if page has been requested if (!isset($_REQUEST['page'])) { $folder_page = "index/Home"; // Page has not been requested, show default page $page = 'index/Home/struct.php'; } else { // request page here $page = $_REQUEST['page']; $folder_page = '/index/'.$page; $page = ('index/'.$page.'/struct.php'); //echo "<!-- CCCCCCCCCCC ".$page." CCCCCCCCCCCC-->"; } // End if page has been requested // Check to see if page exists if (file_exists($page)) { // Page exists // Show page include("./$page"); } else { // Page doesn't exist echo 'Sorry, the page that you are trying to access does not exist.'; } // End if page exists Quote Link to comment 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.