B
B
barma0012020-10-29 14:02:06
Laravel
barma001, 2020-10-29 14:02:06

Laravel in subfolder. How to set up correctly?

Hello,

I am deploying laravel on hosting in a subdirectory.
In principle, everything is put without problems, but there are problems with the paths that I don’t understand how to solve correctly.

The final path to laravel is something like this
uXXXXXX.cp.regruhosting.ru/sites/project_name/public

In css I have background-image
If I make the absolute path background-image: url("/images/bg/main_banner_bg.svg");
then as a result the url is uXXXXXX.cp.regruhosting.ru/images/bg/main_banner_bg.svg
i.e. does not fit sites/project_name/public/

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

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 expand the code.

The option with processCssUrls: false doesn't work either.

I would like to somehow solve this at the .env level, but I didn’t find anything.
Tell me how to solve the issue

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pLavrenov, 2020-10-30
@pLavrenov

./
../

File paths are incorrect.
If the file structure is as follows:
/images/image.png
/css/main.css
then in the *.css file you must specify let ../images/image.png /images/image.png
- will refer to the domain uXXXXXX.cp.regruhosting .ru/images/image.png
images/image.png - will refer to the domain to the current folder + address, if we are in the uXXXXXX.cp.regruhosting.ru/nazvanie-stranitsy/ folder, then the address will be uXXXXXX.cp.regruhosting. ru/nazvanie-stranitsy/images/image.png Image
paths in styles must be specified relative to the css file.
https://school-php.com/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question