How to solve css loading problem and js Ready to work?

Asked

Viewed 1,707 times

1

When I run my local application, the styles and js are loaded normally. The css and js are in public/css and public/js.

In production they are not loaded, below the production . htaccess:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /ambiente

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Code from app.blade.php

<!-- Styles -->
<link href="/css/app.css" rel="stylesheet">

<!-- Scripts -->
<script src="/js/app.js"></script>

What am I doing wrong?

  • Your production configuration is not correct, you use shared hosting?

  • Yes, I use but I use another application also in Laravel that works well. I copied the . htaccess of the application that works and nothing

  • This is the big problem Shared Hosting, the settings never work out, because, the configuration of Laravel is kind of particular even if it has worked out in some other is a mistake to make these settings. Complicated.

  • Virgilio, do you have any accommodation suggestions where I could host my Laravel projects?

  • https://www.heroku.com/

  • 1

    But you can create subdominios or domains in Heroku?

  • http://hoo.st/pt-br

  • has yes @Marcelogomes

  • Virgilio, I’m staying at hoo.st/en. this is the problem.

  • Eita indicated me this little bit on the site Laravel-br.slack.com

  • @Marcelogommes told me this https://forge.laravel.com/ it can be reconciled with Digital Ocean

  • https://www.digitalocean.com/? refcode=619e33cb5d72&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=CopyPaste

  • Marcelo try the following in the html that imports these resources, I assume it is Blade: <link href="{{url('/css/app.css')}}" rel="stylesheet"> and <script src="{{url('/js/app.js')}}"></script>

  • I created an environment variable . env to control 'public' or 'no' folders and it worked with '{{{ url() }}'. Thanks

  • @Marcelogomes sorry to intrude on the conversation... rs but the problem is here Rewritebase /environment your system is in this folder? If you manage to put your entire system in this folder "/ambience" and set up your apache nigx with your system’s domain to point to "/environment/public", I think you’ll have solved your problem there, no?

  • @Marcelogomes only as an option, if you want to opt for a VPS, I really like the AWS of Amazon and OVH, the latter can be a good, cheap start. If you need less latency, you will have to look for something in Brazil. http://ovh.ca

Show 11 more comments

1 answer

1

Try this, remembering that you will have to save the file with this extension .blade.php

<!-- Styles -->
<link href="{{ asset('/css/app.css') }}" rel="stylesheet">

<!-- Scripts -->
<script src="{{ asset('/js/app.js') }}"></script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.