Wednesday 15 August 2012

php - Rewrite rule for pages in one part of site -



php - Rewrite rule for pages in one part of site -

i have pages /admin/adduser have .htaccess rewriterule:

rewriterule ^(index|getreadings|admin)\/([a-za-z]*)$ $1.php?id=$2

on 1 page of site (/getreading/clientlist) there pages want display in url to. how can rewrite rule this? should same must consider pages @ 1 page.

i tried variant:

rewriterule ^(index|getreadings|admin)\/([a-za-z]*)\/([0-9]*)$ $1.php?id=$2&page=$3

but when go simple pages without number in it says page not found. how can it?

here examples: /index/testpage should index?id=testpage now, /getreading/clientlist/1 should index?id=clientlist&page=1

you can have rules this:

rewriterule ^(index|getreadings|admin)/(\w+)/?$ $1.php?id=$2 [l,qsa,nc] rewriterule ^(index|getreadings|admin)/(\w+)/(\d+)/?$ $1.php?id=$2&page=$3 [l,qsa,nc]

php regex apache .htaccess mod-rewrite

No comments:

Post a Comment