我尝试在URL中使用我的Symphony 2项目而没有/ web slug。我已将以下内容添加到我的根文件夹(localhost/subdir)中的.htaccess
文件中。Symfony2将localhost/subdir/web/app.php/action重写为localhost/subdir/action
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
RewriteRule ^web/app_dev.php - [L]
RewriteRule ^web/app.php - [L]
# Fix the bundles folder
RewriteCond %{HTTP_HOST} ^localhost/subdir/$
RewriteRule ^bundles/(.*)$ /web/bundles/$1 [QSA,L]
RewriteCond %{HTTP_HOST} ^localhost/subdir/$
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
#RewriteRule ^(.*)$ /web/app.php [QSA,L]
RewriteRule ^(.*)$ web/app_dev.php [QSA,L]
</IfModule>
这个脚本加载我的网页,但没有得到任何/web/bundle/mybundle/javascript/
,/images/
,或/css/
文件。这些给我一个404错误。因为在<head>
标签中,它表示/bundle/mybundle/javascript/
没有/web
前缀。在web-profiler,调试工具栏等上也是如此。
如何修复我的.htaccess
以使其工作?
本网站有关的编码,而不是有关服务器的配置,你应该尝试另一种如http: //serverfault.com/ – pbenard 2015-03-02 08:34:24