我嘗試在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