为Silex设置ModRewrite - 路由问题

时间:2013-09-01 12:59:01

标签: php apache .htaccess mod-rewrite silex

我已经设置了很多Silex / Symfony应用程序,没有遇到任何问题。我现在只需要使用htaccess功能就可以在共享域上工作。

在Silex文档上进行设置以及浏览后,我将我的.htaccess设置如下: (http://silex.sensiolabs.org/doc/web_servers.html

网站看起来像http://example.com/webpath/to/silex/。此文件位于/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>

这似乎运行良好,除了所有路由包括/ webpath / to / silex /。 IE浏览器。持续NotFoundHttpException: No route found for "GET /webpath/to/silex/home"错误。

我对mod_rewrite的体验很简单,也很有限;我花了一段时间玩弄规则和基地的执行没有任何运气。

如何只将URL的末尾传递给silex应用程序?

1 个答案:

答案 0 :(得分:0)

不确定,但检查......

  • 允许使用mode_rewrite(使用Bash):

    $ sudo a2enmod重写 $ sudo service apache2 restart

  • 你有一个明智的&amp;现有的基本路径值:“/ webpath / to / silex /”真的是否正确?如果对你没用,只需用#来评论这一行