1

I need to have this URL

domain.com/var1/var2/?var3= 
i.e (domain.com/jingle/bells/?id=3033)

to receive parameters this way

domain.com/?var1=&var2=&var3=
i.e. (domain.com/?title=jingle&subtitle=bells&id=3033)

On top of that is it possible to have infinite number of variables after var3? Like:

domain.com/?var1=&var2=&var3=&var4=&var5...

to be

domain.com/var1/var2/?var3=&var4=&var5...

Thank you!!

scully
  • 23
  • 4
  • "I need to have this URL" - Isn't that the other way round? ie. `/var1/var2/?var3=` is the "URL"? However, in your example, `var1` and `var2` are the URL parameter names, not the values? Please clarify. – MrWhite Oct 15 '21 at 10:14
  • Hi @MrWhite you are correct, I'll edit my question! Yes, var1, var2 are parameters as well – scully Oct 15 '21 at 10:17
  • Ok, but this is a rather strange requirement... so the URL parameters have no _values_? – MrWhite Oct 15 '21 at 10:21
  • They do, it was just an example with parameters names. The parameters will receive values that can be anything, like int or char types. I edited the question again. – scully Oct 15 '21 at 10:23
  • Your examples are too abstract to give much specific advice, but this is a pretty straight-forward rewrite once you understand the basic principles. Remember that the "pretty" URL comes in from the browser, and the rewrite rule tells Apache what to do with it, not the other way around. For the additional query string parameters, you just need the "QSA" flag (there's an explanation of what that means on the reference I've linked.) – IMSoP Oct 15 '21 at 10:36
  • @IMSoP thank you, I'm going to try to build it. – scully Oct 15 '21 at 10:43
  • @IMSoP after studying the linked documentation this is what I come up with: RewriteRule ^/([A-Za-z0-9-\+]+)/([A-Za-z0-9-\+]+)/?$ /index.php?section=$1&page=$2 [NC,L,QSA] Would be domain.com/adjustments/chiro/?contact=3920&email=test@test.com translating domain.com/?section=adjustments&page=chiro&contact=3920&email=test@test.com Is that correct? Thank you so much! – scully Oct 15 '21 at 18:10

0 Answers0