# Is directive alias incompatible with module FastCGI?

**URL:** <https://www.ruby-forum.com/t/is-directive-alias-incompatible-with-module-fastcgi/193427>\
**Category:** NGINX\
**Created:** [August 17, 2010, 3:16pm UTC](https://www.ruby-forum.com/t/is-directive-alias-incompatible-with-module-fastcgi/193427 "2010-08-17T15:16:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IPB\_Refugee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e9a140/32.png) [@IPB\_Refugee](https://www.ruby-forum.com/u/IPB_Refugee)\
**Post date:** [August 17, 2010, 3:16pm UTC](https://www.ruby-forum.com/t/is-directive-alias-incompatible-with-module-fastcgi/193427/1 "2010-08-17T15:16:34Z")

</div>

Hello,

at first let me thank you for developing NginX! I use NginX 0.8.48, PHP  
5.3.3 with inbuilt php-fpm version 0.6.5 on CentOS 5.5.

But there is one problem I have been trying to solve for hours without  
success: I want that PHP only gets parsed in an “aliased” subfolder but  
not in the parent location. Is this even possible?

I tried to achieve my aim in several ways, including this one:

```auto
server
{
  listen 80;
  server_name subdomain.example.com;
  root /var/www/example/html;
  index index.html index.php;

  # Igor's suggestion from June 2009:
forum.nginx.org/read.php?2,3059,3060#msg-3060

  location ~ /test/
  {
    alias /var/www/phpmyadmin/;
  }

  location ~ ^/test/(.+\.php)$
  {
    alias /var/www/phpmyadmin/$1;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    include /etc/nginx/fastcgi_params;
  }

  location ~* \.(css|js|jpg|jpeg|gif|png|cur|bmp)$
  {
    access_log off;
    expires 60d;
  }
}
```

PHP should only get parsed in

[color=#0033CC][subdomain.example.com/test/[/color]](http://subdomain.example.com/test/%5B/color%5D) ==  
[color=#CC3300]/var/www/phpmyadmin/[/color]

but not in

[color=#0033CC][subdomain.example.com/[/color]](http://subdomain.example.com/%5B/color%5D) ==  
[color=#CC3300]/var/www/example/html/[/color]

because another person has access to  
[color=#CC3300]/var/www/example/html/[/color] via chrooted SFTP, too.

Unfortunately, index.php in  
[color=#0033CC][subdomain.example.com/test/[/color]](http://subdomain.example.com/test/%5B/color%5D) (at the moment a  
simple [color=#999999]\<?php phpinfo(); ?\>[/color]) doesn’t get parsed  
but is provided for download by Chromium, while Opera shows the source  
code of the PHP file.

I also tried to nest “location” directives and to work with  
“if”, but that didn’t work either. For example:

```auto
location ~* /test/
{
  alias /var/www/phpmyadmin/;

  if ($uri ~ "\.php$")
  {
    fastcgi_pass 127.0.0.1:9000;
  }
}
```

I know that I could simply use a different subdomain for phpmyadmin, but  
I wonder if it’s possible to use FastCGI / PHP together with the  
alias directive.

Any help is appreciated, and if you’d like to see my complete config  
files, just let me know.

Kind greetings from Austria!  
Wolfgang

Posted at Nginx Forum:

> **[Is directive alias incompatible with module FastCGI?](https://forum.nginx.org/read.php?2,120664,120664#msg-120664)**
>
> Hello, at first let me thank you for developing NginX! I use NginX 0.8.48, PHP 5.3.3 with inbuilt php-fpm version 0.6.5 on CentOS 5.5. But there is one problem I have been trying to solve for hours without success: I want that PHP only gets parsed in...

---

<div class="post-metadata">

**Author:** ![IPB\_Refugee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e9a140/32.png) [@IPB\_Refugee](https://www.ruby-forum.com/u/IPB_Refugee)\
**Post date:** [August 28, 2010, 2:28am UTC](https://www.ruby-forum.com/t/is-directive-alias-incompatible-with-module-fastcgi/193427/2 "2010-08-28T02:28:43Z")

</div>

Hello,

I hope it is allowed to bump a topic after 10 days without an answer.

I think it’s simply a bug within nginx. And I hope, it will be resolved  
at some time.

Thanks for reading and have a nice weekend  
Wolfgang

Posted at Nginx Forum:

> **[Re: Is directive alias incompatible with module FastCGI?](https://forum.nginx.org/read.php?2,120664,124489#msg-124489)**
>
> Hello, at first let me thank you for developing NginX! I use NginX 0.8.48, PHP 5.3.3 with inbuilt php-fpm version 0.6.5 on CentOS 5.5. But there is one problem I have been trying to solve for hours without success: I want that PHP only gets parsed in...

---

<div class="post-metadata">

**Author:** ![IPB\_Refugee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e9a140/32.png) [@IPB\_Refugee](https://www.ruby-forum.com/u/IPB_Refugee)\
**Post date:** [August 28, 2010, 6:38am UTC](https://www.ruby-forum.com/t/is-directive-alias-incompatible-with-module-fastcgi/193427/3 "2010-08-28T06:38:38Z")

</div>

On Sat, Aug 28, 2010 at 7:27 AM, IPB\_Refugee [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hello,
> 
> I hope it is allowed to bump a topic after 10 days without an answer.
> 
> I think it’s simply a bug within nginx. And I hope, it will be resolved  
> at some time.

move the

location ~ ^/test/(.+.php)$ { … }

above

location ~ /test/ { … }

(and make it “location /test/ { … }”

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)
