This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

config .htaccess and apache for assets

Discuss installing Symfony 2 here

config .htaccess and apache for assets

by miltone » Mon Jan 27, 2014 4:50 pm

Hello Everybody,

I would like to use Symfony2 with Foundation Framwork CSS. For that, I use the JS and CSS files of Foundation which are put in the resource public in my bundle.

I create a template(base layout) with TWIG and I use the asset function for call JS et CSS files necessary for using Foundation. This seem to be run good at delivery on Apache server local because the analyse of call of the web page (with firebug), I realize that the search asset is locate with this path : /WEB/bundles/.... and not /SRC/bundles. Asset run and translate correctly my path because I run correctly the dump of asset in my console windows before delivery on server.

Also, my Js and CSS files are physically present to my /web path where the web browser search.

But, FireBug warning me that don't find them with error 404 on those location path asset files when it load page.

I'm searching the issue on the config of Apache and the .htaccess (on the /web path) but nothing find. I don't understand where is the problem. What ideal config for run correctly ?

I send you few information of config which now present of my local system.
If you have little few help or lightning for my issue you are so welcome.

Environment :
Windows 7 + Apache 2.4.6 + symfony2 + PHP5.5

- load of rewrite module on Apache
LoadModule rewrite_module modules/

- base directory of htdocs
DocumentRoot "c:/dev/Apache2.4.6/htdocs"
<Directory "c:/dev/Apache2.4.6/htdocs">
Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

- my httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName symfony.local
ServerAlias symfony.local

DocumentRoot "C:/dev/Apache2.4.6/htdocs/symfony/web"
<Directory "C:/dev/Apache2.4.6/htdocs/symfony/web">
# enable the .htaccess rewrites
AllowOverride All
Require all granted

ErrorLog "logs/error.log"
CustomLog "logs/error.log" common

#Pour garder son localhost opérationnel
<VirtualHost *:80>
DocumentRoot "C:/dev/Apache2.4.6/htdocs"
ServerName localhost
ServerAlias localhost

- my hosts file in windows
Code: Select all localhost.localdomain localhost symfony.local

- .htaccess file in root of /web path of symfony
Code: Select all
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]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]
    RewriteRule .? %{ENV:BASE}/app.php [L]
<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
Junior Member
Posts: 2
Joined: Mon Jan 27, 2014 4:18 pm