# Rewrite host

**URL:** <https://www.ruby-forum.com/t/rewrite-host/174080>\
**Category:** NGINX\
**Created:** [August 20, 2009, 3:37pm UTC](https://www.ruby-forum.com/t/rewrite-host/174080 "2009-08-20T15:37:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CactO\_oSs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5daacb/32.png) [@CactO\_oSs](https://www.ruby-forum.com/u/CactO_oSs)\
**Post date:** [August 20, 2009, 3:37pm UTC](https://www.ruby-forum.com/t/rewrite-host/174080/1 "2009-08-20T15:37:54Z")

</div>

Hi all,

I test to rewrite the sub-domain in /etc/nginx/site-available/default  
and I would know if exist a function for add GET argument ?

For example :

if( $host ~\* “(._)._.{2,4}” )  
{  
addGet sd $1;  
}

This code add “?sd=$1” or “&sd=$1” (if there are already arguments GET  
before or not)

If not exist how can I do that ?

Thank you and sorry for my english (I’m french :p)

Posted at Nginx Forum:

> **[\[Nginx Config\] rewrite host](https://forum.nginx.org/read.php?2,5030,5030#msg-5030)**
>
> Hi all, I test to rewrite the sub-domain in \[b\]/etc/nginx/site-available/default\[/b\] and I would know if exist a function for add GET argument ? For example : \[code\] if( $host ~\* "(.\*)\\.\[a-zA-Z0-9\_-\]\*\\.\[a-zA-Z\]{2,4}" ) {

---

<div class="post-metadata">

**Author:** ![CactO\_oSs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5daacb/32.png) [@CactO\_oSs](https://www.ruby-forum.com/u/CactO_oSs)\
**Post date:** [August 25, 2009, 3:18pm UTC](https://www.ruby-forum.com/t/rewrite-host/174080/2 "2009-08-25T15:18:09Z")

</div>

Nobody can help me ?

Posted at Nginx Forum:

> **[Re: \[Nginx Config\] rewrite host](https://forum.nginx.org/read.php?2,5030,5159#msg-5159)**
>
> Hi all, I test to rewrite the sub-domain in \[b\]/etc/nginx/site-available/default\[/b\] and I would know if exist a function for add GET argument ? For example : \[code\] if( $host ~\* "(.\*)\\.\[a-zA-Z0-9\_-\]\*\\.\[a-zA-Z\]{2,4}" ) {

---

<div class="post-metadata">

**Author:** ![CactO\_oSs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5daacb/32.png) [@CactO\_oSs](https://www.ruby-forum.com/u/CactO_oSs)\
**Post date:** [August 25, 2009, 4:13pm UTC](https://www.ruby-forum.com/t/rewrite-host/174080/3 "2009-08-25T16:13:11Z")

</div>

On Thu, Aug 20, 2009 at 7:37 PM, CactO\_o’s[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> }
> 
> This code add “?sd=$1” or “&sd=$1” (if there are already arguments GET before or not)
> 
> If not exist how can I do that ?

rewrite?

---

<div class="post-metadata">

**Author:** ![CactO\_oSs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5daacb/32.png) [@CactO\_oSs](https://www.ruby-forum.com/u/CactO_oSs)\
**Post date:** [August 25, 2009, 4:30pm UTC](https://www.ruby-forum.com/t/rewrite-host/174080/4 "2009-08-25T16:30:45Z")

</div>

> Thank you and sorry for my english (I’m french :p)  
> Hello.

If I understand correctly, you need something like this:

server {  
listen 80;  
server\_name ~(._).._..\*;  
rewrite ^ /$request\_uri&$1;  
}

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,5030,5161#msg-5161](http://forum.nginx.org/read.php?2,5030,5161#msg-5161)
