0

I have in my css file this path to img

.picture{
background:url(../img/once.png)
}

It works on localhost, but it does't on web serwer. I keep this files on web/css and web/img

EDIT:

link This solved my problem

Thank you all for waste your time for my problem ;).

0

3 Answers 3

1

Make sure you have the same webroot at localhost and on your production server. ex:

http://localhost/app.php
http://example.com/app.php

then reference your images in an absolute way

.picture{
   background:url(/img/once.png)
}

relative path in css are always seen from the calling page, not from the css location

Sign up to request clarification or add additional context in comments.

4 Comments

You should configure your webserver correct, that you can omit the /web/ in the url.
regardless of the environment. on production server and localhost.
whats your root directory in your web server?
DocumentRoot /path/to/symfony/web
0

Did you do:

php app/console assets:install web --env=prod
php app/console assetic:dump web --env=prod

?

2 Comments

"I keep this files on web/css and web/img" - assets should be kept within Resources/public folder. That way, when you do assets:install, assetic bundle will make correct paths. Make sure you have cssrewrite: ~ in config.yml (i think it is default)
I put file to Resources/img and /css , I did assets:install and assetic:dump. Now file is loading but is empty.
0

In your layout page, try to do this:

{% block stylesheets %}
   {% stylesheets filter='cssrewrite' 'CSS_PATH/*' %}
{% endblock %}

The cssrewrite is a Twig Filter, google it for mor information.

If this doe's not work, try to:

php app/console cache:clear --env=prod

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.