Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

92
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda