Rewrite multipli con apache.

Rate this post

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.)

You may also like...

Lascia un Commento

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *

È possibile utilizzare questi tag ed attributi XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">