O
O
Oleg2022-04-01 16:28:37
Yii
Oleg, 2022-04-01 16:28:37

How to forward requests to a folder via .htaccess?

Good afternoon, dear experts!

I've lost my feet and can't beat the following problem:

There is a Yii2-advanced project in which an Angular application is planned to be placed on the site in the site.com/lk/* folder.
At the same time, the structure of the project is shown in the screenshot

6246fc80cefc0196263556.png

i.e. all requests of the site.com/lk/* type should go to the /lk/dist/client/* folder.
Moreover, if this is a real file requested (for example, a picture, a style file, etc. in the root or subfolder) - then we return it, otherwise, we direct everything to index.html.

HOW TO DESCRIBE IT IN .htaccess?? ... the option that is described in the screenshot brings down absolutely all requests for index.html - which is naturally not correct.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2022-04-01
@volego

File/.htaccess

# если /lk/
RewriteRule ^lk/(.*)$ lk/dist/client/$1 [L]

File/lk/dist/client/.htaccess
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question