# One domain, two home directories

**URL:** <https://www.ruby-forum.com/t/one-domain-two-home-directories/142143>\
**Category:** NGINX\
**Created:** [July 3, 2008, 8:47pm UTC](https://www.ruby-forum.com/t/one-domain-two-home-directories/142143 "2008-07-03T20:47:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@Emers](https://www.ruby-forum.com/u/Emers)\
**Post date:** [July 3, 2008, 8:47pm UTC](https://www.ruby-forum.com/t/one-domain-two-home-directories/142143/1 "2008-07-03T20:47:49Z")

</div>

Hi there.

I have problem with handling two different home directories into one  
domain. For example my domain is [mydomain.net](http://mydomain.net) and it points to directory  
/home/emers/www/

[…]  
server {  
listen 80;  
server\_name [mydomain.net](http://mydomain.net);  
access\_log /var/log/www/access\_log\_emers combined;  
error\_log /var/log/www/error\_log\_emers error;  
root /home/emers/www;  
index index.html index.htm index.php;

```
     location ~ /\.ht {
         deny all;
     }

     location ~ .*\.php?$ {
         include /etc/nginx/fastcgi.conf;
         fastcgi_pass unix:/tmp/fcgi.socket;
         fastcgi_index index.php;
     }
 }

```

[…]

There is another user account in /home/mail/atmailopen/ with .php and  
.html files.

The question is how to alias [mydomain.net/mail](http://mydomain.net/mail) into  
/home/mail/atmailopen directory? I tried to add location:

```
     location /mail {
         alias /home/poczta/atmailopen/;
     }

```

inside server brackets (included above), then .php files produces “No  
input file specified” message, .html files are showed property.

–  
Regards.

Emers

---

<div class="post-metadata">

**Author:** ![Emers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@Emers](https://www.ruby-forum.com/u/Emers)\
**Post date:** [July 3, 2008, 10:17pm UTC](https://www.ruby-forum.com/t/one-domain-two-home-directories/142143/2 "2008-07-03T22:17:33Z")

</div>

On Thu, Jul 03, 2008 at 08:36:26PM +0200, Emers wrote:

> ```
> root /home/emers/www;
> }
> alias /home/poczta/atmailopen/;
> }
> 
> ```
> 
> inside server brackets (included above), then .php files produces “No  
> input file specified” message, .html files are showed property.

Probably, you need to add the location and rewrite URI to match root:

```
      location ~ ^/mail/.*\.php?$ {

          rewrite ^/mail(.+)$ $1 break;

          root /home/poczta/atmailopen/;
          include /etc/nginx/fastcgi.conf;
          fastcgi_pass unix:/tmp/fcgi.socket;
          fastcgi_index index.php;
      }
```

---

<div class="post-metadata">

**Author:** ![Emers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@Emers](https://www.ruby-forum.com/u/Emers)\
**Post date:** [July 15, 2008, 9:54pm UTC](https://www.ruby-forum.com/t/one-domain-two-home-directories/142143/3 "2008-07-15T21:54:53Z")

</div>

Igor S. wrote:

> > ```
> > access_log /var/log/www/access_log_emers combined;
> > fastcgi_pass unix:/tmp/fcgi.socket;
> > 
> > ```
> 
> ```
> rewrite ^/mail(.+)$ $1 break;
> 
> root /home/poczta/atmailopen/;
> include /etc/nginx/fastcgi.conf;
> fastcgi_pass unix:/tmp/fcgi.socket;
> fastcgi_index index.php;
> }
> 
> ```

Thanks for the answer. Your solution works almost great. Addind two  
followed locations seems to solve the problem, when URI hasn’t folders  
inside mail directory (f.e: [mydomain.com/mail/index.php](http://mydomain.com/mail/index.php)), but scripts in  
subdirectories in /home/mail/atmailopen/\*/ tree redirect to  
[mydomain.com/](http://mydomain.com/) link, instead of [MyDomain Login](http://mydomain.com/mail/).

For example, link in [mydomain.com/mail/install/index.php?step=3](http://mydomain.com/mail/install/index.php?step=3) directs  
to [mydomain.com/install/index.php?step=4](http://mydomain.com/install/index.php?step=4). mail/ is lost.

My locations are as follow:

```
     location /mail {
         alias /home/mail/atmailopen/;
     }
     location ~ ^/mail/.*\.php?$ {
         rewrite ^/mail(.+)$ $1 break;
         root /home/mail/atmailopen/;
         include /etc/nginx/fastcgi.conf;
         fastcgi_pass unix:/tmp/fcgi.socket;
         fastcgi_index index.php;
     }

```

–  
Regards.

Emers
