# Static and dynamic content alias

**URL:** <https://www.ruby-forum.com/t/static-and-dynamic-content-alias/118090>\
**Category:** NGINX\
**Created:** [October 23, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/static-and-dynamic-content-alias/118090 "2007-10-23T20:25:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@Alejandro\_V](https://www.ruby-forum.com/u/Alejandro_V)\
**Post date:** [October 23, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/static-and-dynamic-content-alias/118090/1 "2007-10-23T20:25:51Z")

</div>

me again.

i have those directives to mimic an apache Alias directive that works  
very well.

```
server {
    listen 80;
    server_name ws.lab; #somename alias another.alias;

    location / {
        root /home/website/wsDev/http-dev/;
        index index.php index.html index.htm;
    }
    # Alias mimic begin
    location /phpmyadmin/ {
        alias /usr/share/phpmyadmin/; # alias static content
        index index.php index.html index.htm;
    }
    location ~ /phpmyadmin/(.*).php$ {
        fastcgi_pass 127.0.0.1:8888;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME

```

/usr/share/$fastcgi\_script\_name; # alias dynamic content  
include /etc/nginx/fastcgi\_params;  
}  
# Alias mimic end

```
    # pass the PHP scripts to FastCGI server listening on 

```

127.0.0.1:8888  
#  
location ~ .php$ {  
fastcgi\_pass 127.0.0.1:8888;  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME  
/home/website/wsDev/http-dev$fastcgi\_script\_name;  
include /etc/nginx/fastcgi\_params;  
}  
}

(mainly for the dynamic Alias mimic)  
is there place for a reduction of the settings? or other simpler way?

---

<div class="post-metadata">

**Author:** ![Alejandro\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@Alejandro\_V](https://www.ruby-forum.com/u/Alejandro_V)\
**Post date:** [October 24, 2007, 12:39pm UTC](https://www.ruby-forum.com/t/static-and-dynamic-content-alias/118090/2 "2007-10-24T12:39:13Z")

</div>

On Tue, Oct 23, 2007 at 04:14:53PM -0200, Alejandro V. wrote:

> ```
> }
> # Alias mimic begin
> location /phpmyadmin/ {
> alias /usr/share/phpmyadmin/; # alias static content
> index index.php index.html index.htm;
> }
> 
> ```

nginx allows to set root at any level, so alias is required only if  
URI is not match FS layout. Here you can use

```
      location /phpmyadmin/ {
          root /usr/share;
          index index.php index.html index.htm;
      }

```

> ```
> location ~ /phpmyadmin/(.*).php$ {
> 
> ```

- 

```
    location ~ /phpmyadmin/(.*).php$ {

```

- 

```
    location ~ ^/phpmyadmin/.+\.php$ {

```

> ```
> location ~ .php$ {
> 
> ```

- 

```
    location ~ .php$ {

```

- 

```
    location ~ \.php$ {

```

> ```
> fastcgi_pass 127.0.0.1:8888;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME 
> 
> ```
> 
> /home/website/wsDev/http-dev$fastcgi\_script\_name;  
> include /etc/nginx/fastcgi\_params;  
> }  
> }
> 
> (mainly for the dynamic Alias mimic)  
> is there place for a reduction of the settings? or other simpler way?

No.

---

<div class="post-metadata">

**Author:** ![Alejandro\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@Alejandro\_V](https://www.ruby-forum.com/u/Alejandro_V)\
**Post date:** [October 24, 2007, 3:04pm UTC](https://www.ruby-forum.com/t/static-and-dynamic-content-alias/118090/3 "2007-10-24T15:04:54Z")

</div>

Igor S. escribiÃ³:

> > ```
> > location / {
> > 
> > ```
> 
> nginx allows to set root at any level, so alias is required only if  
> URI is not match FS layout. Here you can use

ok.

> - 
> 
> ```
> location ~ ^/phpmyadmin/.+\.php$ {
> 
> ```
> 
> > ```
> > # pass the PHP scripts to FastCGI server listening on 127.0.0.1:8888
> > fastcgi_param SCRIPT_FILENAME 
> > 
> > ```

ok, thanks.
