You are here: Re: Mod_Rewrite / Regex to PHP URL « PHP Programming Language « IT news, forums, messages
Re: Mod_Rewrite / Regex to PHP URL

Posted by Rik on 02/15/07 01:12

On Thu, 15 Feb 2007 00:15:34 +0100, Dr. No <no@no.no> wrote:

> I am new to using mod_rewrite and am trying to rewrite a URL to pass =

> values to my script so that:
>
> http://www.myclient.com/everything/animals/mammals/cats
>
> is transformed into
>
> http://www.myclient.com/index.php?nav[0]=3Deverything&nav[1]=3Danimal=
s&nav[2]=3Dmammals@nav[3]=3Dcats
>
> Specifically, I am looking for an n-ary solution to this problem. I kn=
ow =

> how to do it for a discrete number, but how do I do this transformatio=
n =

> when the number of variables to go into the nav array is unknown, and =
=

> how do I generate the index number? Can any experience mod_rewrite gur=
us =

> point me in the right direction. I'm sure this is a common design =

> pattern.

As far as I know you cannot, not without really messy toying with =

environmental variables.

As you're using PHP, what's wrong with:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?nav=3D$1

And in PHP:

$nav =3D isset($_GET['nav']) ? explode('/',$_GET['nav']) : array();
-- =

Rik Wasmus

 

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

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