开发者

Symfony2 Asset Resource Path

In my apache2 settings for /etc/apache2/sites-available/default, I make my website configuration like this :

Alias /new/  "/var/www/symfony/web/"
Alias /new"/var/www/symfony/web/"
<Directory "/var/www/symfony/web">
    AllowOverride All
    Order allow,deny
    Allow from xxx.xxx.xxx.xxx
</Directory>

And I already enable apache2 rewrite module.

When I access www.example.com/new/app.php, the resources load fine (css, javascript and image). The generated source code almost looks like this:

<link href="/new/css/main.css" ..... />
.....

But when I access www.example.com/new, the resources DON'T LOAD AT ALL. When I view the source code, it almost 开发者_如何学运维looks like this:

<link href="/css/main.css" ..... />
.....

Firebug said:

www.example.com/css/main.css - 404 Not Found
www.example.com/images/logo.jpg - 404 Not Found
.....

What should I do?


Add a .htaccess file in your /web directory with the following code :

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    # Explicitly disable rewriting for front controllers
    RewriteRule ^app_dev.php - [L]
    RewriteRule ^app.php - [L]

    RewriteCond %{REQUEST_FILENAME} !-f

    # Change below before deploying to production
    #RewriteRule ^(.*)$ /app.php [QSA,L]
    RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>

If it still doesn't work you might use standard Vhost configuration, take a look to VirtualHost Examples on Apache Website.

For assetic issues go to see the Asset management documentation about that.

I hope this help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜