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. Link to comment https://forums.phpfreaks.com/topic/207973-custom-url-help/ 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 Link to comment https://forums.phpfreaks.com/topic/207973-custom-url-help/#findComment-1087222 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 Link to comment https://forums.phpfreaks.com/topic/207973-custom-url-help/#findComment-1087224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.