VirtualHost rewrite rules for Silex

November 9, 2011

After seeing Igor Wiedler's presentation on symfony Day I really wanted to try SIlex. It's a PHP micro-framework that seems especially well-suited for creating small sites and API's.

The Silex documentation lists the Apache rewrite rules when using a .htaccess file:

  <IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine On
    #RewriteBase /path/to/app
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
  </IfModule>

But if possible, I put the Apache rewrite rules into the VirtualHost configuration. This requires to change the rules a bit. Namely adding a slash to index.php.

VirtualHost settings:

    Options -MultiViews

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ /index.php [L]

So I hope this will be useful to someone. Happy coding!

Free fonts for presentations »

0 Responses to VirtualHost rewrite rules for Silex

    There are currently no comments.

Comments are closed for this post