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

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

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -