[.HTACCESS] vreemd probleempje...

Pagina: 1
Acties:

  • GewoonNico
  • Registratie: April 2003
  • Laatst online: 23-04 16:32
Hallo,

Ik heb de volgende HTACCESS
code:
1
2
3
4
5
6
7
8
9
10
11
12
RewriteEngine On

RewriteRule ^nl/album.html http://www.partypassion.net/index.php?lang=nl&pid=album/home
RewriteRule ^nl/album/(.*)_(.*)/image_(.*).html http://www.partypassion.net/index.php?lang=nl&pid=album/image&id=$3
RewriteRule ^nl/album/(.*)_(.*)/index_(.*).html http://www.partypassion.net/index.php?lang=nl&pid=album/album&id=$1&from=$3
RewriteRule ^nl/news/(.*)_(.*).html http://www.partypassion.net/index.php?lang=nl&pid=news/view&id=$1
RewriteRule ^nl/location/client(.*)_(.*).html http://www.partypassion.net/index.php?lang=nl&pid=location/view_client&id=$1
RewriteRule ^nl/location/(.*)_(.*).html http://www.partypassion.net/index.php?lang=nl&pid=location/view&id=$1
RewriteRule ^nl/member/set_propage_(.*)_(.*).html http://www.partypassion.net/index.php?lang=nl&pid=member/set_propage&what=$1&num=$2
RewriteRule ^nl/guestbook/index_(.*).html http://www.partypassion.net/index.php?lang=nl&pid=guestbook/home&from=$1

RewriteRule ^nl/(.*).html http://www.partypassion.net/index.php?lang=nl&get=$1


Stel, ik roep de volgende pagina op ht*p://www.partypassion.net/nl/album/219_Music_4_everybody/index_0.html, dan werkt dat perfect en zonder problemen. Maar, als ik dan een echo doe van het ID (219) dan krijg ik het volgende: 219_Music_4. Het lijkt er dus op dat album/(.*)_(.*)/ pas bij de laatste _ gesplit wordt,terwijl mijn bedoeling was om het bij de 1e _ te splitten. Hoe los ik dit op?

(de query's werken overigens wel gewoon, ondanks dat er een fout ID wordt meegegeven.)

[ Voor 11% gewijzigd door GewoonNico op 21-11-2005 09:21 ]


  • RvdH
  • Registratie: Juni 1999
  • Laatst online: 17-04 13:47

RvdH

Uitvinder van RickRAID

Maak van alle (.*) het volgende: (.+?)

Hiermee pas je de 'greediness' aan.
Uit perldoc perlre:
By default, a quantified subpattern is "greedy", that is, it will match
as many times as possible (given a particular starting location) while
still allowing the rest of the pattern to match. If you want it to
match the minimum number of times possible, follow the quantifier with
a "?". Note that the meanings donât change, just the "greediness":

*? Match 0 or more times
+? Match 1 or more times
?? Match 0 or 1 time
{n}? Match exactly n times
{n,}? Match at least n times
{n,m}? Match at least n but not more than m times

  • GewoonNico
  • Registratie: April 2003
  • Laatst online: 23-04 16:32
Dank U, het werkt.