How can I rewrite .php files properly?

Joergi nginx-forum at
Mon Jun 19 19:32:43 UTC 2017

Hi guys,

I am running a MediaWiki installation and I am using this block of rules to
rewrite requests to MediaWiki:

location ~ \.php {
    root /home/$username/www/;
    index index.php index.html;
    try_files /dummy/$uri @php;

However, this is creating the problem that wiki pages, which end on .php can
no longer be accessed. Instead, nginx only responds with "File not found."

What can I do to make all requests still go to MediaWiki, but to then let
MediaWiki handle the actual paths?

E.g. a request to MyWikiPages/File.php should still be passed to MediaWiki,
but then MediaWiki should display the according wiki page.



Posted at Nginx Forum:,274971,274971#msg-274971

More information about the nginx mailing list