Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

91
Views
React.js in subfolder and htaccess

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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]
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!