All you need to do is create a .htaccess file in your projects root and put this inside:
RewriteRule !\.(ico|gif|jpg|png|css|js|swf|flv)$ index.php [QSA]
The RewriteRule stated above will redirect all requests matching the Pattern “!\.(ico|gif|jpg|png|css|js|swf|flv)$” to index.php (the pattern being anything not ending with any of the extensions listed in the brackets). The [QSA] flag stands for Query String Append, meaning that any query string passed with the URL will be appended to the rewritten URL.
A NOTE ON .htaccess:
Full documentation on how to use .htaccess can be found here.
The use of .htaccess should be limited to certain scenarios, and Apache’s main configuration file should be used instead, as stated in the documentation:
However, in general, use of
.htaccessfiles should be avoided when possible. Any configuration that you would consider putting in a
.htaccessfile, can just as effectively be made in a
<Directory>section in your main server configuration file.
There are two main reasons to avoid the use of
The first of these is performance. When
AllowOverrideis set to allow the use of
.htaccessfiles, httpd will look in every directory for
.htaccessfiles. Thus, permitting
.htaccessfiles causes a performance hit, whether or not you actually even use them! Also, the
.htaccessfile is loaded every time a document is requested.
The second consideration is one of security. You are permitting users to modify server configuration, which may result in changes over which you have no control. Carefully consider whether you want to give your users this privilege.
DO IT THE PROPER WAY WITH APACHE’S CONFIGURATION FILE!