Configure apache to handle all requests via single index.php

Solution 1:

OK, without mod_rewrite. mod_rewrite is the answer, of course, but this uses mod_alias:

RedirectMatch permanent ^/(?<!index\.php)(.*) http://example.com/index.php

This should match anything that isn't preceded by index.php and issue a permanant redirect to the correct index.php. Note that you'll need to specify the full location as the target.

Updated I've tested the above and it needs Apache 2.0+ as it uses PCRE. If you need the actual path appending to index.php, then append $1 to the redirect path.

Solution 2:

LoadModule rewrite_module     /usr/lib/apache/modules/mod_rewrite.so

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/?index.php$
RewriteRule . index.php

Solution 3:

Save the following into a file named .htaccess in your web root.

# Turn on URL rewriting
RewriteEngine On

# Web Directory
RewriteBase /

# Protect certain folders from being viewed
RewriteRule ^(protected|directories) - [F,L]

# Rewrite URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

Solution 4:

You may do this with a mod_rewrite rule.

#.htaccess code
RewriteEngine On
RewriteRule ^(.*)$ index.php [L]