Why am I needing to add ampersand manually in rewrites?

In a Wordpress/Buddypress installation, I am having to go through all my
code and manually insert ampersands. For example, where there are links
to things such as “?r=user” I am having to convert that into “?&r=user”
in order for the link to do the required function. Or when it says
“?_wpnonce” I am needing to change it to “?&_wpnonce”.

Am I missing something? Is there an easy rewrite rule I can use for
Nginx to fix this?

I am on Nginx only, not using it as a proxy to Apache.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,188044,188044#msg-188044

On Sun, 2011-04-03 at 18:00 -0400, jamz wrote:

In a Wordpress/Buddypress installation, I am having to go through all my
code and manually insert ampersands. For example, where there are links
to things such as “?r=user” I am having to convert that into “?&r=user”
in order for the link to do the required function. Or when it says
“?_wpnonce” I am needing to change it to “?&_wpnonce”.

Why would you need to do this?

& and ? don’t go next to each other. ? indicates the start of query
arguments and & separates them.

?_wpnonce : correct
?&_wponce : incorrect
?&r=user : incorrect
?_wponce&r=user : correct

Regards,
Cliff

Just to clarify – this is the tutorial I followed:

http://endofweb.co.uk/2010/10/ubuntu-vps-nginx-mysql-php-fpm-phpmyadmin-wordpress/

In my vhost file I had to add client_max_body_size 60M, and in
nginx.conf I configured gzip but otherwise everything’s about the same
setup. I’m on nginx 0.8.54.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,188044,188099#msg-188099

What I’m saying is that my links don’t work correctly unless I do that.
I have no idea why. For example, when I could click a link that would
take me to something/some?_wpnonce1234 it would take me to an error page
that said “are you sure you want to do this?” but when I added the
ampersand, it worked as designed. so something/some?&_wpnonce1234 would
work. So now I’ve gone through my whole site and into the WP and BP core
and added ampersands everywhere and my site is fully functional on
Nginx.

I have Nginx with PHP FPM and the Nginx compatibility plugin for php5. I
set it up on a VPS from scratch following a tutorial and it’s all been
great except for this one issue.

Anybody know why this would ever occur?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,188044,188097#msg-188097

On Mon, 2011-04-04 at 00:49 -0400, jamz wrote:

Just to clarify – this is the tutorial I followed:

http://endofweb.co.uk/2010/10/ubuntu-vps-nginx-mysql-php-fpm-phpmyadmin-wordpress/

In my vhost file I had to add client_max_body_size 60M, and in
nginx.conf I configured gzip but otherwise everything’s about the same
setup. I’m on nginx 0.8.54.

I think you must have gotten something wrong. I’d start by
double-checking at the vhost config. The “fix” you are doing is not
correct.

Regards,
Cliff

Hi,

Haven’t looked at your conf, but you likely forgot a ? at the end of
the target in your rewrite statement.
Have a look at http://wiki.nginx.org/HttpRewriteModule#rewrite
(especially the part after “To rewrite a URL with parameters to
another URL, use this instead:”).

You could also have a look at the WP configuration examples here :
http://kbeezie.com/view/nginx-configuration-examples/

Good luck with it.

Antoine.

Thanks for your help, Cliff. I have a feeling that what you say is
spot-on. Perhaps from that tutorial I have added in some kind of
redirect or something that is causing the ? links to not work without an
appended &. It’s really weird. Maybe I should try replacing the & with
another ?. If I’m removing the first ? by default, that would make sense
then. Although, I have checked the site across many browsers now, and
everything is working exactly how it should. Load times are extremely
fast. Before, I got lots of error messages. So while this fix isn’t
necessarily correct, it seems to be working, and as I’ve repeated it
across different links, they all start to work. So I’m going to roll
with it for now…I’m on a time crunch to get this up. I’ll have to look
more into it later.

Until then, if you or anyone thinks of anything, please make a shout :slight_smile:

Jon

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,188044,188110#msg-188110

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs