为Silex设置ModRewrite - 路由问题

I've set up quite a few Silex/Symfony apps, without ever having problems. I now need to work on a shared domain only with htaccess capability.

Following setup on the Silex documentation, along with browsing around, I set up my .htaccess as follows: (http://silex.sensiolabs.org/doc/web_servers.html)

Website looks like http://example.com/webpath/to/silex/. This file is in /drive/path/to/silex/.htaccess

<IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine On
    RewriteBase /webpath/to/silex/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)? web/index_dev.php/$1 [QSA,L]
</IfModule>

This seems to work well, aside from all routing includes the /webpath/to/silex/. IE. Continual NotFoundHttpException: No route found for "GET /webpath/to/silex/home" errors.

My experience with mod_rewrite has been simple and limited; I've spent a while playing around with permatations of the Rule and the Base without any luck.

How can I pass just the end of the URL to the silex app?

Not sure, but check that...

  • mode_rewrite is allowed (using Bash) :

    $ sudo a2enmod rewrite $ sudo service apache2 restart

  • you've got a sensible & existing base path value: Is "/webpath/to/silex/" really correct ? Just comment this line with a #, if it's useless to you