My .htaccess
file is like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
And my index.php
:
echo '<pre>';
print_r(explode('/', $_SERVER['REQUEST_URI']));
echo '</pre>';
When I go to example.com/test/one/two
, it gives me back:
Array
(
[0] =>
[1] => test
[2] => one
[3] => two
)
Why is there a 0?
Because your $_SERVER['REQUEST_URI']
is /test/one/two
.
To get rid of that you could remove first slash from $_SERVER['REQUEST_URI']
:
substr($_SERVER['REQUEST_URI'], 1);