Jump to content

Custom URL help


rsquaredpgh

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.