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

366
Views
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 answers
Answer question

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 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!