You are here: Re: Pretty URLs « PHP Programming Language « IT news, forums, messages
Re: Pretty URLs

Posted by Andy Jeffries on 03/06/06 10:55

On Sat, 04 Mar 2006 15:03:56 -0800, Laeronai wrote:
> I'm making a blog cms and have been having trouble with making the URLs
> look good. Each post goes to a URL like "viewpost.php?id=40" but I want
> the URL to look like "YYYY/MM/TITLE" so it would come out to be
> "/2006/03/hey-look-its-march." Does anyone know how to do this in PHP?

As another example you could put the following at the top of your
viewpost.php script:

<?php
list($ignore, $year, $month, $title) = explode($_SERVER["PATH_INFO"]);
?>

And link to:

/viewpost.php/2006/03/hey-look-its-march

The server will use viewpost.php as the script and put anything after the
script name that looks like a path into $_SERVER["PATH_INFO"].

Cheers,


Andy


--
Andy Jeffries | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация