Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've a Suffix Proxy installed and I'm using the following rewrite with wildcard subdomain DNS on:

location / {
     if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php last;
        break;
     }
}

My suffix proxy has the following URL format: (subdomain and/or domain + domain extension to proxy).proxy.org/(request-uri to proxy)

I've this php code in my index.php:

if(preg_match('#([\w\.-]+)\.example\.com(.+)#', $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'], $match)) {
    header('Location: http://example.com/browse.php?u=http://'.$match[1].$match[2]);
    die;
}

But when requested a page with a .php extension I'll get a 404 not found error:

http://www.php.net.proxy.org/docs.php - HTTP/1.1 404 Not Found
http://www.utexas.edu.proxy.org/learn/php/ex3.php - HTTP/1.1 404 Not Found

But everything else is working (also index.php is working):

http://php.net.proxy.org/index.php - HTTP/1.1 200 OK
http://www.php-scripts.com.proxy.org/php_diary/example2.php3 - HTTP/1.1 200 OK
http://www.utexas.edu.proxy.org/learn/php/ex3.phps - HTTP/1.1 200 OK
http://www.w3schools.com.proxy.org/html/default.asp - HTTP/1.1 200 OK

Somebody has an answer? I don't know why it's not working, on apache it's working fine.

Thanks in advance.

I've removed the location and now it's working perfectly:

if (!-e $request_filename) {
     rewrite ^(.*)$ /index.php last;
     break;
}
share|improve this question

1 Answer 1

I could not fully understand your question. But, it looks like you may want to add try_files in your location block, something like this...

location / {
     if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php last;
        break;
     }

     try_files $uri =404;
}

I hope this helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.