I have http://example.com
and a PHP routing class that checks if some URL exists.
I want to make a new route, which is:
http://example.com/
I guess this could help. "/index.php" will delegate to the wrong path.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
Since Apache 2.2.16:
FallbackResource /index.php
You can handle the URI with php:
.htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
php:
if (isset($_SERVER['REQUEST_URI']))
{
$params = explode("/", ltrim($_SERVER['REQUEST_URI'], "/"));
print_r($params);
}
example.com/just/these/params
Output:
Array
(
[0] => just
[1] => these
[2] => params
)
RewriteRule ^(.*)$ /$1.php [L]
Try it like this. In you .htaccess every request that isn't a file on disk is redirected to index.php, I am guessing that index.php is redirecting further. I don't think you can get this route /foo/bar/123 or /foo/bar with just one line of code. Every page needs it own rewrite rule. Could you be more specific?