By allangodoys
Consider the following example URI
http://teste.com/test.php/8455
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_pass 127.0.0.1:10000;
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;
}
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @allangodoys,
I’ll suggest making the requests like
http://teste.com/test.php?8455=something
or
http://teste.com/test.php?8455
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, Kalin
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.