# Apache to nginx rewrite rule

**URL:** <https://www.ruby-forum.com/t/apache-to-nginx-rewrite-rule/193944>\
**Category:** NGINX\
**Created:** [August 26, 2010, 10:37pm UTC](https://www.ruby-forum.com/t/apache-to-nginx-rewrite-rule/193944 "2010-08-26T22:37:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![khine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c67d28/32.png) [@khine](https://www.ruby-forum.com/u/khine)\
**Post date:** [August 26, 2010, 10:37pm UTC](https://www.ruby-forum.com/t/apache-to-nginx-rewrite-rule/193944/1 "2010-08-26T22:37:58Z")

</div>

hello, what is the way to convert this apache vhost directive to nginx?

```auto

  ServerName example.com
  ServerAlias vhost1.example.com
  ServerAlias vhost2.example.com
  RewriteEngine On
  RewriteRule ^/(.*) http://localhost:8080/$1 [P]

```

also is there a way to read a list of ServerAlias’es dynamically, for  
example from a python list, [‘[vhost1.example.com](http://vhost1.example.com)’,  
‘[vhost2.example.com](http://vhost2.example.com)’…]

thanks

norman

Posted at Nginx Forum:

> **[apache to nginx rewrite rule.](https://forum.nginx.org/read.php?2,124052,124052#msg-124052)**
>
> hello, what is the way to convert this apache vhost directive to nginx? \[code\] \<VirtualHost \*:80\> ServerName example.com ServerAlias vhost1.example.com ServerAlias vhost2.example.com RewriteEngine On RewriteRule ^/(.\*) http://localhost

---

<div class="post-metadata">

**Author:** ![khine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c67d28/32.png) [@khine](https://www.ruby-forum.com/u/khine)\
**Post date:** [August 26, 2010, 11:52pm UTC](https://www.ruby-forum.com/t/apache-to-nginx-rewrite-rule/193944/2 "2010-08-26T23:52:54Z")

</div>

server {  
server\_name [example.com](http://example.com) [vhost1.example.com](http://vhost1.example.com) [vhost2.example.com](http://vhost2.example.com);  
proxy\_pass [http://localhost:8080](http://localhost:8080);  
}

---

<div class="post-metadata">

**Author:** ![khine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c67d28/32.png) [@khine](https://www.ruby-forum.com/u/khine)\
**Post date:** [August 27, 2010, 7:28am UTC](https://www.ruby-forum.com/t/apache-to-nginx-rewrite-rule/193944/3 "2010-08-27T07:28:17Z")

</div>

great, thanks

Posted at Nginx Forum:

> **[Re: apache to nginx rewrite rule.](https://forum.nginx.org/read.php?2,124052,124161#msg-124161)**
>
> hello, what is the way to convert this apache vhost directive to nginx? \[code\] \<VirtualHost \*:80\> ServerName example.com ServerAlias vhost1.example.com ServerAlias vhost2.example.com RewriteEngine On RewriteRule ^/(.\*) http://localhost
