Roubi
Roubi

Reputation: 2106

Symfony 4 : setup webroot in dev so browser can access files generated with webpack encore

In DEV, I'm accessing my website using this URL: http://localhost/my_project/public/index.php

I'm using WebpackEncore, and when I load my page, the browser tries to load assets (css and js generated in build directory) with paths where the my_project/public part is missing e.g.

http://localhost/build/app.js but browsers expects something like:

http://localhost/my_project/public/build/app.js

I'm not familiar with redirections and .htaccess. I have been told I should set my webroot to solve this, so I guess that if I made my Apache root be my_project/public then it would work but I'm working on different projects and I don't want to change this parameter each time I switch form one project to another. Maybe this can be solved using an .htaccess ? Or setting up something else in Symfony config ?

Upvotes: 0

Views: 227

Answers (1)

Rikijs
Rikijs

Reputation: 808

You should look into Apache VirtualHost feature. You can configure one virtual host for each of your projects. This way all your projects will be accessible.

Upvotes: 1

Related Questions