2

I'm trying to catch everything after /project/ until the last slash, even if there's a slash in between. Is this possible?

/project/code-cons/isting-0f_all-ch/ars/

rewrite to:

/project/?id=code-cons/isting-0f_all-ch/ars

I previously used this rule:

RewriteRule ^project/([^/]+)/?$ index.php?pagename=project&id=$1 [L]

But that does not take slashes in the project id into account and so does not match the rule.

KeyNone
  • 8,745
  • 4
  • 34
  • 51
Vincent
  • 324
  • 1
  • 8

1 Answers1

3

Yes you can use this regex:

RewriteRule ^project/(.+?)/?$ index.php?pagename=project&id=$1 [L,QSA]

(.+?) is non-greedy regex that will capture everything until last optional regex is found.

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 2
    OP may want to take a look [here](http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid) depending on how valid he/she would like the string to be. `.+?` literally entails *any* character. – tenub Jan 09 '14 at 18:04