Rewrite multipli con apache.

Da questo post:

1 vote down

Here’s a solution which will loop over key/value pairs in your URL:

RewriteRule ^cat_ap~([^~]+)~([^~]+)(.*)\.htm$ cat_ap$1?$1=$2 [R,QSA]
RewriteRule ^cat_ap(.*)\.htm$ /urban/cat_ap.php [L]

It grabs the first pair off the URL, then rewrites it to the exact same URL without that pair, adds the pair to the query string ([QSA]) and starts the rewriting process over again ([R]). When there are no more key/value pairs in the URL, it rewrites it to your script’s location and terminates rewriting ([L]).

cat_ap~pnid~290~nid~96666~posters~Sports.htm => /urban/cat_ap.php?posters=Sports&nid=96666&pnid=290
cat_ap~PageNum_GetProduct~10~nid~290.htm => /urban/cat_ap.php?nid=290&PageNum_GetProduct=10

(Note that the order of parameters is reversed; this will only matter if the same parameter appears more than once.)

Condividi:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • email
  • Google Bookmarks
  • LinkedIn
  • PDF
  • Reddit
Nessun commento ancora

Lascia un commento

XHTML: Puoi usare questi tag: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word