I haven't found a solution in Apache for this. The only solution I've found for this is in handling it in PHP which almost defeats the purpose of using FallbackResource /index.php
in the first place.
if (preg_match('#^/index.php#', $_SERVER['REQUEST_URI'])) {
$redirect = preg_replace('#^/index.php#', '', $_SERVER['REQUEST_URI']);
if (empty($redirect)) {
$redirect = '/'; // in case request is domain.com/index.php with no trailing slash
}
header('Location: ' . $redirect);
exit;
}
This is not ideal but it works. It's odd there's so little information about the duplicate URLs issue with FallbackResource
. Nevertheless, this solution did not suffice IMO so what I did personally is go back to mod_rewrite.
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
Hope this helps you at least. I tried a bounty but nobody seems to have an answer.