#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    76
    Rep Power
    11

    Optional portion of Regular Expression


    Hello all,

    I am currently using the rollowing RewriteRule;

    Code:
    RewriteRule ^admin/news/edit/([0-9]+)/$ admin/news.php?sitePage=news&pageSection=newsForm&nId=$1
    I basically want to be able to have an optional part of the url between "admin" and "news". For instance;

    /admin/value/news/edit
    or
    /admin/news/edit

    but still wrapping it all up in the same line, rather than creating an extra line for each additional defintion.

    Thanks!

    Matt.
    Regards, Matt Lowden
    http://www.mattlowden.com
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,112
    Rep Power
    9398
    Do you want to do something with that "value"? Or just throw it away?
    What all is allowed in there? Anything? Just letters and numbers? Is there a specific list of things it can be?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    1
    Rep Power
    0
    Originally Posted by BlazerRotare
    l,
    /admin/value/news/edit
    or
    /admin/news/edit
    Hello,

    I think the expression ^admin/(.+\/)*edit/([0-9]+)/$ should do it

IMN logo majestic logo threadwatch logo seochat tools logo