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

367
Visualizações
How to set nginx redirection to mvc php app?

I have problem with redirection from nginx to php mvc app, because all requests sending from nginx are looking for directory. I would like to send url as params to let the routes in app menage them. Both of them are on different servers.

.htaccess in app:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} !\.(css|js|png|jpg|svg|json|pdf|php)$ [NC]

    RewriteRule ^([^/]+)/? index.php?url=$1 [L,QSA]
</IfModule>

in nginx i tried:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

May i ask for advice how to configure redirection from nginx to mvc app. Is there any tag in header of request which tells the server that request looking for directory?

Example: https://site.domain/Users

In this example Users is a directory, i would like to use it as "string param"

Example of request i received in app:

IP - - [26/Mar/2020:15:13:20 +0000] "GET /Application/Admin?id=1322323 HTTP/1.0" 403 466 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0

In this example Application is root directorywhich work correct but after "/" is a Folder.. no param string..

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

For nginx the following is sufficient (you don't need any query parameter bindings - they'll work just fine)

location ~ ^/ { try_files $uri $uri/ /index.php; }

For Apache I would

RewriteRule ^(.*)$ index.php?url=$1&%{QUERY_STRING} [L,R=301]

let us know the result

over 4 years ago · Santiago Trujillo 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