+1 vote

Deploying laravel on the hosting subdirectory.
In principle, all put without problems, but there are problems with the paths that I do not understand how to properly solve.

The final path to laravel looks something like this

I have a background-image in my css
If I make the absolute path background-image: url("/images/bg/main_banner_bg.svg");
the resulting url is uXXXXXX.cp.regruhosting.ru/images/bg/main_banner_bg.svg
i.e. sites/project_name/public/ is not included.

If relative then background-image: url("images/bg/main_banner_bg.svg");
The output is uXXXXXX.cp.regruhosting.ru/sites/project_name/publ...
I.e. css is added and therefore nothing works

The option with mix.setResourceRoot('/sites/project_name/public'); and relative paths works if processCssUrls: true works, but it's tedious to uncomment this line every time you unfold the code.

The processCssUrls: false option doesn't work either.

I would like to solve this somehow at the .env level, but I can't find anything.
Please advise how to solve the problem

1 Answer

0 votes

Incorrectly specified file paths.

If the file structure is like this:

then in the *.css file you must specify let ../images/image.png

/images/image.png- will link to the domain uXXXXXX.cp.regruhosting.ru/images/image.png
images/image.png- will link the domain to the current folder + address, if we are in the folder uXXXXXX.cp.regruhosting.ru/nazvanie-stranitsy/the address will be uXXXXXX.cp.regruhosting.ru/nazvanie-stranitsy/images/image.png

The picture paths in the styles should be specified relative to the css file.