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

1 Answer 1

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.

1
  • 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 8, 2015 at 21:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .