# Rewrite rule with in url

**URL:** <https://www.ruby-forum.com/t/rewrite-rule-with-in-url/241743>\
**Category:** NGINX\
**Created:** [April 28, 2015, 10:22am UTC](https://www.ruby-forum.com/t/rewrite-rule-with-in-url/241743 "2015-04-28T10:22:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [April 28, 2015, 10:22am UTC](https://www.ruby-forum.com/t/rewrite-rule-with-in-url/241743/1 "2015-04-28T10:22:39Z")

</div>

Hi - I’ve got a plugin which was misconfigured - and now I need to  
rewrite a  
string - however I cannot find out at all how to do this for urls with ?  
in  
them.

So I need to have:  
[www.velomap.org/de/?s2member\_paypal\_notify=1](http://www.velomap.org/de/?s2member_paypal_notify=1)  
rewritten to [www.velomap.org/?s2member\_paypal\_notify=1](http://www.velomap.org/?s2member_paypal_notify=1)  
(note the /de missing).

I tried:  
server { server\_name [www.velomap.org/de/?s2member\_paypal\_notify=1](http://www.velomap.org/de/?s2member_paypal_notify=1)  
return 301  
$scheme://www.velomap.org/?s2member\_paypal\_notify=1$request\_uri?;  
}

but this is not accepted as valid nginx.conf…

So I need this rewritten and it is important that whatever string is  
following this is not lost…

(also - but less important) - how can I rewrite a specific url?  
So I want to rewrite

> **[VeloMap.org - Fahrrad, Rennrad -Karten basierend auf Openstreetmap](https://www.velomap.org/de/)**
>
> VeloMap provides you with free garmin cycling maps worldwide - based on openstreetmap VeloMap bietet Fahrrad und Rennrad Karten für Garmin weltweit basierend auf Openstreetmap

to [www.velomap.org](http://www.velomap.org)

- but only if it is exactly this url. [VeloMap.org - Fahrrad, Rennrad -Karten basierend auf Openstreetmap](http://www.velomap.org/de) as well as  
[www.velomap.org/de/\*](http://www.velomap.org/de/*) is not allowed to be rewritten…

Posted at Nginx Forum:

> **[rewrite rule with ? in url](https://forum.nginx.org/read.php?2,258420,258420#msg-258420)**
>
> Hi - I've got a plugin which was misconfigured - and now I need to rewrite a string - however I cannot find out at all how to do this for urls with ? in them. So I need to have: www.velomap.org/de/?s2member\_paypal\_notify=1 rewritten to...

---

<div class="post-metadata">

**Author:** ![extremecarver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e19adc/32.png) [@extremecarver](https://www.ruby-forum.com/u/extremecarver)\
**Post date:** [April 28, 2015, 10:55am UTC](https://www.ruby-forum.com/t/rewrite-rule-with-in-url/241743/2 "2015-04-28T10:55:22Z")

</div>

Will this work correctly with all the arguments followed?

location = /de/ {  
if ( $arg\_s2member\_paypal\_notify ) {  
rewrite ^ / permanent;  
}  
}

Posted at Nginx Forum:

> **[Re: rewrite rule with ? in url](https://forum.nginx.org/read.php?2,258420,258422#msg-258422)**
>
> Hi - I've got a plugin which was misconfigured - and now I need to rewrite a string - however I cannot find out at all how to do this for urls with ? in them. So I need to have: www.velomap.org/de/?s2member\_paypal\_notify=1 rewritten to...

---

<div class="post-metadata">

**Author:** ![extremecarver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e19adc/32.png) [@extremecarver](https://www.ruby-forum.com/u/extremecarver)\
**Post date:** [April 28, 2015, 11:05am UTC](https://www.ruby-forum.com/t/rewrite-rule-with-in-url/241743/3 "2015-04-28T11:05:53Z")

</div>

okay - I noticed my homepage wouldn’t load for [VeloMap.org - Fahrrad, Rennrad -Karten basierend auf Openstreetmap](http://www.velomap.org/de/)  
anymore  
with this rule -

location = /de/ {  
if ( $arg\_s2member\_paypal\_notify ) {  
rewrite ^ / permanent;  
}  
try\_files $uri $uri/ /index.php;  
}

Seems to work - well I hope this is passing on all information correctly  
still…

Posted at Nginx Forum:

> **[Re: rewrite rule with ? in url](https://forum.nginx.org/read.php?2,258420,258424#msg-258424)**
>
> Hi - I've got a plugin which was misconfigured - and now I need to rewrite a string - however I cannot find out at all how to do this for urls with ? in them. So I need to have: www.velomap.org/de/?s2member\_paypal\_notify=1 rewritten to...
