0

I am having a problem with my project assets when deploying them in a shared hosting. The point is that on my development server, I can create virtual host without any problems but in the shared hosting I have not this possibility when more I can create a subdomain and point it to the web project folder.

In my local server I created a virtual host and pointing to /var/www/html/tanane and I access trough URL as tanane (ServerName) but in a shared hosting but this varies a bit and the content of the project is inside a subfolder in the root path, for example: /public_html/tanane and I reach it from the URLtanane.com/tanane/web/. Apparently this is causing a issue and assets are lost and many fail to load, mostly those with sources like Twitter Bootstrap and FontAwesome. I have tried everything as you can see in this post but I have not accomplished anything yet.

This is what I did til now:

  • Try this syntax {{ asset('/bundles/css/somecss.css') }} works for some but others not, example.

    Problem: The CSS rule

    .contactenos, .contactenos:hover, .e-shop, .e-shop:hover, .faq, .faq:hover, .fctjur, .fctjur:hover, .fctnat, .fctnat:hover, .vendidos, .vendidos:hover {
        background: url(/bundles/template/images/sprites.png) no-repeat;
    } 
    

    works fine on local server but in shared hosting I need to change to:

    .contactenos, .contactenos:hover, .e-shop, .e-shop:hover, .faq, .faq:hover, .fctjur, .fctjur:hover, .fctnat, .fctnat:hover, .vendidos, .vendidos:hover {
        background: url(/tanane/web/bundles/template/images/sprites.png) no-repeat;
    } 
    

    Which not works at local server then.

    • As the post I leave shows, I tried a lot of things with Assetic without success. Can anyone suggest me something else? Perhaps something in .htaccess or some other place? Any help, advice?
Community
  • 1
  • 1
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • Can you run app/console on your shared host? – Cerad Sep 16 '14 at 16:21
  • did you try to use the path relative to your CSS file? like ../template/images/sprites.png – Jacobson Sep 16 '14 at 16:23
  • @Cerad I don't think so, I just setup all in my development server,and upload all except `/app/cache` folder, is the only way I know to deploy in a shared hosting without SSH access – ReynierPM Sep 16 '14 at 16:23
  • I'm lucky enough to have ssh access. @Jacobson's solution will probably help. I'd suggest setting up your local machine to match your shared host so the exact same urls are used. Might make trouble shooting easier. – Cerad Sep 16 '14 at 16:32
  • @Cerad SOT but, which hosting did you use? Or you have a VPS or something else? – ReynierPM Sep 16 '14 at 16:34
  • 1
    I use telavant.com. They give me full ssh access to my account. Been with them since 2005. – Cerad Sep 16 '14 at 16:36

1 Answers1

1

Try to use relative paths on your CSS.

.contactenos, .contactenos:hover, .e-shop, .e-shop:hover, .faq, .faq:hover, .fctjur, .fctjur:hover, .fctnat, .fctnat:hover, .vendidos, .vendidos:hover {
    background: url(../template/images/sprites.png) no-repeat;
} 
Jacobson
  • 674
  • 5
  • 10