Welcome! Log In Create A New Profile

Advanced

PHP Front controller exceptions

Posted by mappu 
PHP Front controller exceptions
July 21, 2012 08:43PM
Hi, you probably get this question a lot but i havn't come across an answer...

I have a wiki that hosts user-generated content with URLs like /wiki/view/pagename and /wiki/modify/pagename. I'm using something like:

location /wiki/ {
    try_files $uri $uri/ /wiki/index.php?q=$uri&$args;
}
location ~ \.php$ {
    try_files $uri =404;
    #fastcgi stuff...
}

It's been working great and as far as i can tell, this is the recommended approach. However, today, a user created a page named "whatever.php", so it needs the URLs /wiki/view/whatever.php to be redirected to my /wiki/index.php... but it gets caught in the second location block and returns a 404 to the user-agent.

Does anyone have any suggestions? Can i add an extra location block to rewrite *.php to the main script somewhere in such a way that won't affect actually routing pages? I would prefer not to go to the extent of whitelisting individual php files and folders in the nginx conf...
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 152
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready