Consider the following example URI

When accessing this on Apache the apache send the request to the “test.php” file. However when accessing the same URI on nginx with php-fpm he gave an not found error, why does it behaves different and how can i make they have the same behavior ?

This is my .htacces redirect configuration:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond %{ENV:REDIRECT_STATUS} 200 [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

And this is my nginx server configuration

server {
    listen   80;
    root /var/www/html;
    index index.php index.html;
    location ~ .php$ {
            try_files $request_uri $request_uri/ =404;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;

    location / {
        try_files $request_uri =404;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/www;

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Hi @allangodoys,

I’ll suggest making the requests like 


As I believe this is the proper way of handling such requests. If you want to keep the current convention, try to pass the $query_string variable in nginx:

try_files $uri $uri/ /index.php/$query_string;

Kind regards,

Submit an Answer