2

I am in this situation:

url: domain/var1/var2/var3/.../varn

And I want to change that url in:

url: domain?v1=var1&v2=var2&v3=var3/.../&vn=varn

I found this way:

RewriteRule domain/([^/]+)/([^/]+)$ domain/index.php?v1=$1&v2=$2 [QSA,NC]

But as you can see I have to specify all the vars manually... Is there a way to do it automatically? Something like: while there is a /([^/]+) add v{N}=${N} ?

Thanks

Francesco
  • 121
  • 3

1 Answers1

0

You can do a while loop, but AFAIK rewrite engine does not provide a loop counter.

RewriteEngine On
RewriteRule ^/?domain/([^/]+)/?([^?]+)/?$ /domain/$2/?piece[]=$1 [QSA,N=50]
RewriteRule . domain/index.php [L,NS]

php will parse into the array _GET['piece'].

I'm really curious why you're not using php to parse the url.

h0tw1r3
  • 2,746
  • 18
  • 17
  • What would you do? (I read about the "tecnic" of put the request url in a GET var and parse that with php) – Francesco Dec 08 '15 at 21:33