# Why am I needing to add ampersand manually in rewrites?

**URL:** <https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316>\
**Category:** NGINX\
**Created:** [April 4, 2011, 12:01am UTC](https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316 "2011-04-04T00:01:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 4, 2011, 12:01am UTC](https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316/1 "2011-04-04T00:01:34Z")

</div>

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:

> **[Why am I needing to add ampersand manually in rewrites?](https://forum.nginx.org/read.php?2,188044,188044#msg-188044)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![jamz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@jamz](https://www.ruby-forum.com/u/jamz)\
**Post date:** [April 4, 2011, 5:56am UTC](https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316/2 "2011-04-04T05:56:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jamz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@jamz](https://www.ruby-forum.com/u/jamz)\
**Post date:** [April 4, 2011, 6:49am UTC](https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316/3 "2011-04-04T06:49:37Z")

</div>

Just to clarify – this is the tutorial I followed:

[http://endofweb.co.uk/2010/10/ubuntu-vps-nginx-mysql-php-fpm-phpmyadmin-wordpress/](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:

> **[Re: Why am I needing to add ampersand manually in rewrites?](https://forum.nginx.org/read.php?2,188044,188099#msg-188099)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![jamz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@jamz](https://www.ruby-forum.com/u/jamz)\
**Post date:** [April 4, 2011, 6:40am UTC](https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316/4 "2011-04-04T06:40:21Z")

</div>

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:

> **[Re: Why am I needing to add ampersand manually in rewrites?](https://forum.nginx.org/read.php?2,188044,188097#msg-188097)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![jamz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@jamz](https://www.ruby-forum.com/u/jamz)\
**Post date:** [April 4, 2011, 7:24am UTC](https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316/5 "2011-04-04T07:24:45Z")

</div>

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/](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

---

<div class="post-metadata">

**Author:** ![jamz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@jamz](https://www.ruby-forum.com/u/jamz)\
**Post date:** [April 5, 2011, 3:17pm UTC](https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316/6 "2011-04-05T15:17:59Z")

</div>

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 [Module ngx\_http\_rewrite\_module](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/](http://kbeezie.com/view/nginx-configuration-examples/)

Good luck with it.

Antoine.

---

<div class="post-metadata">

**Author:** ![jamz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@jamz](https://www.ruby-forum.com/u/jamz)\
**Post date:** [April 4, 2011, 7:54am UTC](https://www.ruby-forum.com/t/why-am-i-needing-to-add-ampersand-manually-in-rewrites/205316/7 "2011-04-04T07:54:59Z")

</div>

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 🙂

Jon

Posted at Nginx Forum:

> **[Re: Why am I needing to add ampersand manually in rewrites?](https://forum.nginx.org/read.php?2,188044,188110#msg-188110)**
>
> 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...
