i think this is a bit of a noob question, but here goes.
I am trying to get a better understanding $_GET variables in PHP. A lot of CMS's etc convert things like site.com/?ID=42 into something like site.com/42
My question is, what happens to the $_GET variables when this happens? I try and print the GET array on page load, and it is empty.
The way they do this is using mod_rewrite
Basically you have the webserver "rewrite" URI requests to something else, so you have incoming requests like
http://your.site.com/Page/arg1/arg2/arg3
But with your REWRITE RULE, you'll have Apache turn requests that match this pattern (all requests bound for /Page) into:
http://your.site.com/Page?a=arg1&b=arg2&c=arg3
You'd then finally in PHP have $_GET[ 'a' ], $_GET[ 'b' ] and $_GET[ 'c' ] all set to values.
Check out this book
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With