Re: Creating User Friendly URLS
| From: | Ray Hauge | Date: | Thu, 17 Aug 2006 14:58:35 +0000 |
| Subject: | Re: Creating User Friendly URLS | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240806@lists.php.net to get a copy of this message | ||
On Thursday 17 August 2006 09:43, Dave M G wrote:
> PHP List,
>
> My goal is to create user and search engine friendly URLs like:
> mysite.com/my_web_page_title
>
> Instead of:
> mysite.com/index.php?pageID=1
>
> I asked about this before:
> ? º•[EO2�
> n®P¸«Õhttp://marc.theaimsgroup.com/?l=php-general&m=113597988027012&w=2
>
> And there is this helpful tutorial:
>
> http://agachi.name/weblog/archives/2005/01/30/rewriting-dynamic-urls-into-f
>riendly-urls.htm
>
>
> Both of which refer to a variable called $_SERVER['PATH_INFO'].
>
> But, in the php.net manual, in the predefined variables page,
> 'PATH_INFO' is only obliquely referenced in the $_SERVER variable
> description, under the 'PATH_TRANSLATED' element.
>
> When I've tried echoing out the contents of $_SERVER['PATH_INFO'], I get
> nothing.
>
> I'm trying to set it so that pages are named according to their title in
> my MySQL database. So my script will pull "my_web_page_title" out of the
> URL, match that against the database, and then display the appropriate
> contents.
>
> I thought I could do this by simply making my link into:
> <a href="index.php/my_web_page_title">My Web Page Title</a>
>
> And then stripping out the "index.php", and using the remainder for
> both the URL and the database lookup.
>
> But, while I'm sure there are more steps than that, I'm halted initially
> because I'm not sure where in the $_SERVER array my URL is being stored.
>
> Any advice on how to proceed here would be greatly appreciated. Thank you.
>
> --
> Dave M G
Richard has a good article related to this. Mostly it's about how to force a
download with a correct filename, but the last part of the article should get
you pointed in the right direction if you don't want to use mod_rewrite with
apache.
http://richardlynch.blogspot.com/
--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099