Welcome! Log In Create A New Profile


Truncating file extensions

Posted by Josh 
Truncating file extensions
October 23, 2009 05:36PM

Is there anyway to serve a file without using the extension? Example: search?q=foo, where search.php would reside in document root. Currently it gives a 404. Apache2 does this out of the box, and lighttpd has mod_magnet for this.

Re: Truncating file extensions
October 28, 2009 06:29PM

Try using this rewrite inside your server { } part and before your first location { }, it worked fine on my server :

server {
listen 80;
server_name site.com;
server_name_in_redirect off;
access_log /var/log/nginx/site.access_log main;
error_log /var/log/nginx/site.error_log debug;
root /home/www/site;

rewrite ^(.*)(search?)(.*)$ $1search.php?$3 break;

location / {

location ~ .*\.php$ {

Edited 1 time(s). Last edit at 10/28/2009 06:30PM by Revy.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 85
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready