I am attempting to catch every URL and rewrite it to index.php. I've the next code during my .htaccess at this time:

RewriteEngine on
RewriteRule .* index.php

It will rewrite every URL, however i always obtain a 404 saying the index.php file can't be found. The road it's searching for the file is correct though. What shall we be held doing wrong here?


Update 1

After I directly browse to index.php, it will properly display the file. Very strange.


Update 2

I switched on logging for mod_rewrite by using this in httpd.conf:

RewriteLog /var/log/apache2/rewrite.log
RewriteLevel 3

This is exactly what it drenched:

strip per-dir prefix: /Users/rits/Sites/test/ -> 
applying pattern '.*' to uri ''
rewrite '' -> 'index.php'
add per-dir prefix: index.php -> /Users/rits/Sites/test/index.php
internal redirect with /Users/rits/Sites/test/index.php [INTERNAL REDIRECT]

I am fairly sure the reason being it's attempting to rewrite index.php to index.php infinitely.

Try the next rather:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !index\.php
RewriteRule .* index.php

Which should prevent spinning to itself, and hopefully fix your condition.

Do this:

RewriteEngine on
RewriteRule ^(.*)$ http://www.yourwebpage.com/$1 [L,R=301]

This is actually the .htaccess in one of my websites which i established to redirect everything towards the index page and delay pills work for me personally, if you want to check it out:

RewriteEngine on
RewriteOptions MaxRedirects=10
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !index\.php
RewriteRule ^.*$ http://www.mywebpage.com/ [R=301,L]