为symfony2路由重写request_uri

时间:2014-04-08 14:49:55

标签: .htaccess symfony mod-rewrite

我需要在我的网站上重写所有地址:

http://domain.com/toto/myPage
http://domain.com/myPage

问题在于,当我修改我的.htaccess以在所有路径中自动添加前缀时,symfony(2)不会处理它,所有路由最终都会到达404 ...

如何编辑我的.htaccess来修改REQUEST_URI? 这不起作用:

<IfModule mod_rewrite.c>
    # Rewrite all other queries to the front controller.
    RewriteRule .? %{ENV:BASE}/app.php/toto [L]
</IfModule>

由于

1 个答案:

答案 0 :(得分:0)

我们找到了一种解决方法(所以问题仍然有效)。

但对于工业化,我们创建了一个文件

app/config/routing.yml.dist

包含所有主bundle路由声明,我们从build中删除了routing.yml。 因此,我们只需复制每个域的源,并编辑routing.yml文件以删除更改所需捆绑包上的前缀。 这样我们就可以继续共享数据库了。

但我仍然对如何使用.htaccess文件感到好奇。