You are here: Re: clean urls mod_rewrite and mysql...howto « PHP Programming Language « IT news, forums, messages
Re: clean urls mod_rewrite and mysql...howto

Posted by Geradeaus on 08/16/07 07:29

On 7 aug, 15:24, gosha bine <stereof...@gmail.com> wrote:
> On 07.08.2007 11:11 Geradeaus wrote:
>
>
>
> > I use mod_rewrite all the time, but I was still asking myself how you
> > combine it with a database.
>
> > e.g. you have an article with the title : "Mac, windows or linux. Who
> > will tell?"
>
> > so I can get something like this : http:///www.domain.com/article/mac-windows-or-linux-who-will-tell
> > What should I do?
>
> > 1. just urlencode the title (but then I have problems with the ,
> > and .)
>
> > 2. use a regular expression to filter out the special characters
> > (replace spaces and ", ." by "-" ... etc) and save the filtered-title
> > into the database? When I want to search for this article I just
> > perform a regular expression on the title string and search for it in
> > the databse: WHERE title = ".regularexpressionfunction($title)."
>
> > 3. Or don't you save this title into the database, but do you always
> > perform this regular expression while searching in the database? e.g.
> > WHERE REGEX(title) LIKE '".regularexpressionfunction($title)."'
>
> > I have been googling for a long time, but I can't find a descent
> > article about this ...
>
> > thanks for your help!
>
> A title to url conversion is simple
>
> function title_to_url($title) {
> preg_match_all('/\w+/', strtolower($title), $m);
> return implode('-', $m[0]);
>
> }
>
> echo title_to_url("Mac, windows or linux. Who will tell?");
>
> The opposite (given an url, find an article) is far more complicated.
> There are two approaches: store url in the database, as others
> suggested, or split an url to words and perform the full text search for
> those words. The latter has an advantage that users will be able to use
> different urls to access the same article, e.g.
>
> http:///www.domain.com/article/linux-who-will-tell
>
> or
>
> http:///www.domain.com/article/linux-mac-windows
>
> etc.
>
> --
> gosha bine
>
> makrell ~http://www.tagarga.com/blok/makrell
> php done right ;)http://code.google.com/p/pihipi

Thanks,

maybe the solution to save the title to url conversion is the best
indeed... thanks for all your help!

 

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

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