如果你的httpd.conf说允许压倒一切的
NameVirtualHost *:80
<VirtualHost *:80>
ServerName foo.localhost.com
DocumentRoot "/Projects/YourProject/web"
<Directory "/Projects/YourProject/web">
Options Indexes FollowSymLinks
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
您可以使用此Web/.htacces
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app_dev.php [L] ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the startpage to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /app_dev.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
一定ifmodule启用; link
所以在您的督促环境你app.php
取代app_dev.php您可能还需要为每个环境不同的参数,最好要做到这一点是把它变成的.gitignore 创造两个文件:
parameters.prod.yml
parameters.dev.yml
,并根据阶段创建parameters.yml文件在同一目录就像一个符号链接:
ln -s parameters.dev.yml parameters.yml
您是否尝试过从网址中移除app_dev.php?如果你已经启用了mod_rewrite并且你的.htaccess没有被改变,那么它应该可以直接使用。欲了解更多信息,请参阅http://symfony.com/doc/current/quick_tour/the_big_picture.html#what-is-an-environment – qooplmao