I have backend (Symfony) and frontend (React.js).
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(api/.*)$ public/index.php?/$1 [L,QSA,PT]
RewriteRule ^$ /fe/build/ [L]
I neeed forward requests beginning by /api to public/index.php. It's working.
Problem is with frontend. I need other requests forward to fe/build folder where index.html with all assets.
Now I get content of fe/build/index.html but I have problem with loading assets.
In console I have following error:
static/js/main.97d34693.js NOT FOUND
I think that static/js/main.97d34693.js is loading from root folder and not from fe/build folder. Somebody know what am I doing bad?
RewriteRule ^$ /fe/build/ [L]
You are only forwarding requests for the root. If you "need [all] other requests forward to..." then you need to remove the $ (end-of-string anchor) on the RewriteRule pattern. For example:
RewriteRule ^ /fe/build/ [L]
However, this assumes you have another .htaccess file at /fe/build/.htaccess containing mod_rewrite directives associated with your frontend/reactjs routing. If not then change the rule to the following instead in order to prevent rewriting requests for itself:
RewriteRule !^fe/build/ /fe/build/ [L]