title: How do I create a people-friendly URL using an alias and ID from database?
body: <p>I have created a simple CMS in which each article has an id, title, alias (for URL), introtext, fulltext, etc. as:</p>
  
  <pre><code>create table articles (
      id int auto_increment primary key,
      title varchar(80),
      alias varchar(80),
      introtext text,
      fulltext text,
      published tinyint(1),
      date date
  )
  </code></pre>
  
  <p>To access an article using the ID is easy and the URL will look something like:</p>
  
  <pre><code>www.mysite.com/article?id=31
  </code></pre>
  
  <p>or perhaps
      www.mysite.com/article?menuid=3&amp;id=31</p>
  
  <p>In my database the article looks like:</p>
  
  <p>id: 3
  title: This is my life
  alias: this-is-my-life
  introtext: yadda ... yadda</p>
  
  <p>The goal is to take the alias field and use it to create a people-friendly URL as:</p>
  
  <pre><code>www.mysite.com/this-is-my-life.php
  </code></pre>
  
  <p>or</p>
  
  <pre><code>www.mysite.com/index.php?article=this-is-my-life
  </code></pre>
  
  <p>or </p>
  
  <pre><code>www.mysite.com/?article=this-is-my-life
  </code></pre>
  
  <p>In any case the article id is used to obtain the alias from the table and the alias becomes the basis of the people-friendly URL.</p>
  
  <p>I see this regularly done in CMS like Joomla and Wordpress, perhaps even zen-cart. The question is how do you accomplish this with a PHP script or redirect function in the .htaccess?</p>
  
  <p><strong>New information (Jan. 23)</strong></p>
  
  <p>We seem to be talking apples to oranges as I am not understanding how this is supposed to work. Perhaps a link to a simplified demo site where you can see the menu ID structure in action will help.</p>
  
  <p><a href="http://dottedi.us/test" rel="nofollow">http://dottedi.us/test</a></p>
  
  <p>This is slightly more complicated than the initial example but follows the same general idea. The live demo is based upon using the joomla menu manager to create the menu item including the URL and the optional alias. it looks like:</p>
  
  <p>www.dottedi.us/test/index.php?option=com_k2&amp;view=item&amp;layout=item&amp;id=5</p>
  
  <p>Joomla and probably the other CMS systems (Wordpress, Drupal, etc) has a global configuration parameter to enable what they call SEO-friendly URLs. I call them people-friendly. It would take the above URL and convert it to the people friendly version employing the alias field from the table so the above URL would become</p>
  
  <p>www.dottedi.us/test/about.php (with or without the .php suffix)</p>
  
  <p>Rather than use the link field as the visible URL I could use the alias field so that it will look like about.php when you hover over it, but I am confused how to make it return the live URL. You can see this at:</p>
  
  <p><a href="http://dottedi.us/test2" rel="nofollow">http://dottedi.us/test2</a></p>
  
  <p>I added some debugging output which you can see if you scroll to the bottom of a page. Does this help?</p>