regex - htaccess - combine rewrites into single -


i have couple of rewriterules i'd combine one. i'm not sure how it, though. think arounds need used? difference between 2 first match like:

search/foo or search/foo/

and second match

search/foo/10 or search/foo/10/

rewrites:

rewriterule ^search/([a-za-z]+)/?$ index.php?page=search&query=$1&pn=1 [l] rewriterule ^search/([a-za-z]+)/([0-9]+)/?$ index.php?page=search&query=$1&pn=$2 [l] 

without using arounds, attempt

^search/([a-za-z]+)/?([0-9]+)?/?$

but think match undesirable this?

search/foo10

edit:

i'm tryin regex match following uris:

  1. search/foo
  2. search/foo/
  3. search/foo/1
  4. search/foo/1/

^search/([a-za-z]+)(/)?([0-9]+)?\/?$  

will work? might have make '/' match pattern , ignore $2.same can followed trailing '/' , ignore $4.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -