Www.example.com/about/?ref=example.com

Hi all, tried doing a bit of research on Google about this but found nothing. I have seen a couple of websites that use clean URLs but will have a question mark with some variables in the URL. I have tried getting these variables but nothing happens. How is this done?

Here is my rewrite rule:

RewriteRule ^(.*)/$ index.php?main_page=$1 [L]

Change [L] to [L,QSA] :slight_smile:

QSA stands for Query String Append and puts everything that was in the original query string back in the new query string.

What does your rule do btw? It looks pretty nasty with that (.*) in there.

Hey bud, thanks for the prompt reply. It just rewrites my URLs so I have /contact/, /about/, etc. Oooo is it nasty? What should I use instead? I’ve added QSA and it’s working perfectly, thanks for the info and help.

It’s better to accept only paths you know you want to have, instead of (.*) which will accept everything and anything.

So say you only have contact and about, better would be:


RewriteRule ^(contact|about)/$ index.php?main_page=$1 [L]

contact|about means “contact or about”, which you can easily extend.
If you add “home” it simply becomes contact|about|home

HTH :slight_smile:

Hi Scallio, cheers for the pointers, I did not realize this could be done, makes a lot more sense. Thanks again, massive help dude :slight_smile:

cox,

What you don’t realize is that (.*) will also match each and every redirection you provide and generate a loop (which the Apache developers have limited to 10 retries). If you’re going to use the :kaioken: EVERYTHING :kaioken: atom, know that you must provide an exclusion for the redirection (if nothing else - like .css, .jpg, .gif, .js, etc. ad nauseum).

Regards,

DK