Because $_GET
contains the variables in the query string - that's the part of the URL after the question mark. Notice that the rewriting rules in your .htaccess
file turn all URLS that do not refer to existing files or directories into just index.php
, without any trace of the original URL (though, as Gumbo's comment reminded me, it's still accessible via $_SERVER['REQUEST_URI']
. Your RewriteRule
s don't create a query string (i.e. they don't put a question mark into the URL), which is what you'd need to do to use $_GET
.
I would suggest replacing your last RewriteRule
with something like
RewriteRule ^.*$ index.php$0 [NC,L]
That $0
will append the original URL to index.php
- so for example, http://localhost/index/index/test/1234/test2/4321
will become http://localhost/index.php/index/index/test/1234/test2/4321
Then the request will be handled by index.php
and the $_SERVER['PATH_INFO']
variable will be set to the original URL, /index/index/test/1234/test2/4321
. You can write some PHP code to parse that and pick out whatever parameters you want.
If you don't want the /index/index
at the beginning to be saved in the path_info variable, you can use a RewriteRule
like this instead:
RewriteRule ^/index/index(.*)$ index.php$1 [NC,L]
or
RewriteRule ^(/index)*(.*)$ index.php$2 [NC,L]
to strip off any number of leading /index
es.
EDIT: actually, you can keep your existing RewriteRule
s and just look at $_SERVER['REQUEST_URI']
to get the original request URI; no messing around with the path info is needed. Then you can split that up as you like in PHP.