Nginx Drupal Rewrite

Hendry Lee hendry.lee at gmail.com
Wed May 20 17:22:09 MSD 2009


> So, just to make clear: this
>
>  try_files $uri $uri/ /foo/index.php?q=$request_uri;
>
> does not work, but this
>
>  try_files $uri $uri/ /foo/index.php?q=$uri&$args;
>
> works.

Correct.

> How does Drupal go with zero $args ? I.e., /foo/index.php?$uri& ?

Failed too, as reported by someone earlier. $args is crucial in try_files
for Drupal to work. This is a sample of url that generated an error.

Http://example.com/request/ajax/handle?operation=validate_url&url=http%3A%2F
%2Fgoogle.com%2F

When the PHP code checked the 'operation' variable, as in

if ($_REQUEST['operation']), it returned false.

With try_files $uri $uri/ /foo/index.php?q=$request_uri; it acts exactly
like my previous rewrite line. 

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

-- 
Hendry







More information about the nginx mailing list