Nginx Drupal Rewrite

On Sat, May 16, 2009 at 01:46:06PM -0700, Michael S. wrote:

I will say I did notice the behavior for Drupal and possibly other
apps that require GET parameters. I’ve noted it in a blog post:

The Life and Times of Michael Shadle » Don’t forget the $args!

Does Drupal understand

try_files $uri $uri/ /foo/index.php?u=$irequest_uri;

instead of

try_files $uri $uri/ /foo/index.php?u=$uri&$args;

?

On Sun, May 17, 2009 at 09:47:32AM +0400, Igor S. wrote:

On Sat, May 16, 2009 at 01:46:06PM -0700, Michael S. wrote:

I will say I did notice the behavior for Drupal and possibly other
apps that require GET parameters. I’ve noted it in a blog post:

The Life and Times of Michael Shadle » Don’t forget the $args!

Does Drupal understand

try_files $uri $uri/ /foo/index.php?u=$irequest_uri;

  • try_files $uri $uri/ /foo/index.php?u=$irequest_uri;
  • try_files $uri $uri/ /foo/index.php?u=$request_uri;

I will say I did notice the behavior for Drupal and possibly other
apps that require GET parameters. I’ve noted it in a blog post:

http://michaelshadle.com/2009/05/15/dont-forget-the-args/

2009/5/16 Igor S. [email protected]:

I figured it out. It was the way index was specified.

I’m on 0.6.35… is this the suggested version to be running?

  • try_files $uri $uri/ /foo/index.php?u=$irequest_uri;
  • try_files $uri $uri/ /foo/index.php?u=$request_uri;

This doesn’t work. With q or u variables. I tried it on an installation
of
Drupal with clean url. The request failed during an AJAX request.

index.php?q=$uri&$args works though.

Notice it’s ‘q=’ not ‘u=’

-Hendry

+! for 0.7.x

been running it since i started, no complaints.

On Tue, 2009-05-19 at 12:00 -0500, AMP Admin wrote:

I’m on 0.6.35… is this the suggested version to be running?

Depends on who you ask. Some prefer the stable series, others (like
me) prefer the development branch.

Cliff

No problems here either, and I’ve been upgrading all our production
servers to the 0.7.x versions. Of course, I wait a few days and watch
the mailing list for any bugreports :slight_smile:

On Tue, May 19, 2009 at 12:00:52PM -0500, AMP Admin wrote:

I’m on 0.6.35… is this the suggested version to be running?

I’m going to branch 0.8 development version and mark 0.7 as stable on
this or the next week.

The “development” branch has more frequent changes, hence it’s referred
to as such.

The “stable” branch has fewer version releases, hence it is referred to
as such.

New features are added to the development branch, and sometimes ported
to the stable branch, sometimes not.

There are many large sites running the development branch, and quite a
few running the stable branch, and still a fair number running a legacy
version (0.5.x or perhaps earlier).

There are bugs in all of them (probably), as bug fixes are often part of
new releases in both the stable and development branches.

I always run the latest development release on the forum, currently
0.7.58.

Posted at Nginx Forum:

On Sun, May 17, 2009 at 02:43:08PM +0700, Hendry Lee wrote:

  • try_files $uri $uri/ /foo/index.php?u=$irequest_uri;
  • try_files $uri $uri/ /foo/index.php?u=$request_uri;

This doesn’t work. With q or u variables. I tried it on an installation of
Drupal with clean url. The request failed during an AJAX request.

index.php?q=$uri&$args works though.

Notice it’s ‘q=’ not ‘u=’

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.

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

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;
}

On Wed, May 20, 2009 at 08:22:09PM +0700, Hendry Lee wrote:

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.

No, I meant how does Drupal go with trailing “&”, if an original request
has no query string at all, say

/some/page.html

will be //foo/index.php?q=/some/page.html&

2009/5/20 Igor S. [email protected]:

No, I meant how does Drupal go with trailing “&”, if an original request
has no query string at all, say

/some/page.html

will be //foo/index.php?q=/some/page.html&

I think this assumes Drupal is running with friendly URLs enabled,
which are extensionless, and also, the PHP script will see that as a
single parameter still, just ‘q’

Since the slug /some/page.html is ‘q’, the & will be ignored as it is
a standard query string.

I think WordPress might do it slightly differently in how it parses
the URI, which is why it worked without $args (at least it appeared to
for a long time for me) - Drupal apparently needs the args passed to
it, whereas WordPress probably grabs the URI from another source (and
actually you might be able to pass nothing to the index.php and it
handles it from PATH_INFO. I think.)

No, I meant how does Drupal go with trailing “&”, if an original request
has no query string at all, say

/some/page.html

will be //foo/index.php?q=/some/page.html&

Tested that. Everything works fine. Just that I can’t have parameters in
the
URL. For that I need to add $args.

Drupal clean url doesn’t have extension, but I tried /submit, /node/1,
and
other longer urls, they all work fine.

-Hendry

On Wed, May 20, 2009 at 09:43:45AM -0700, Michael S. wrote:

which are extensionless, and also, the PHP script will see that as a
handles it from PATH_INFO. I think.)
Probably WordPress gets URI from REQUEST_URI.

2009/5/20 Igor S. [email protected]:

Probably WordPress gets URI from REQUEST_URI.

Yeah, WordPress handles it a little bit better, and accepts multiple
styles of input and figures it out. Drupal is a bit more strict.

Both work fine with $args, but Drupal seems to require $args.