# Index directive not taking effect in case of alias

**URL:** <https://www.ruby-forum.com/t/index-directive-not-taking-effect-in-case-of-alias/222382>\
**Category:** NGINX\
**Created:** [August 27, 2012, 2:01pm UTC](https://www.ruby-forum.com/t/index-directive-not-taking-effect-in-case-of-alias/222382 "2012-08-27T14:01:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 27, 2012, 2:01pm UTC](https://www.ruby-forum.com/t/index-directive-not-taking-effect-in-case-of-alias/222382/1 "2012-08-27T14:01:28Z")

</div>

I would like the pnp4nagios app to be accessed as:  
[http://server/pnp4nagios/](http://server/pnp4nagios/). With this URL it gives a 403 Forbidden error.  
It  
works when I give: [http://server/pnp4nagios/index.php](http://server/pnp4nagios/index.php).  
What might be wrong?

Here is the pnp4nagios location config:

```
location ~ /pnp4nagios {
    alias $pnp4nagiosbase/share;
    auth_basic "Nagios Restricted"; ## Message shown in 

```

login  
window  
auth\_basic\_user\_file $nagiosbase/etc/htpasswd.users ; ## See  
/etc/nginx/htpassword  
index index.php;  
try\_files $uri $uri/ @handler ; ## If missing pass the URI to  
Magento’s front handler

```
    location ~ /([^\/]*\.php)$ {
        alias $pnp4nagiosbase/share/$1;
        #include /etc/nginx/fastcgi.conf;
        fastcgi_pass $fcgipass;
        fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
        include fastcgi_params; ## See 

```

/etc/nginx/fastcgi\_params  
}

```
    location ~ \.php$ {
        #include /etc/nginx/fastcgi.conf;
        include fastcgi_params; ## See 

```

/etc/nginx/fastcgi\_params  
fastcgi\_pass $fcgipass;  
}

```
}

```

Thanks,  
Yash

Posted at Nginx Forum:

> **[index directive not taking effect in case of alias](https://forum.nginx.org/read.php?2,229985,229985#msg-229985)**
>
> I would like the pnp4nagios app to be accessed as: http://server/pnp4nagios/. With this URL it gives a 403 Forbidden error. It works when I give: http://server/pnp4nagios/index.php. What might be wrong? Here is the pnp4nagios location config:...

---

<div class="post-metadata">

**Author:** ![yashgt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yashgt](https://www.ruby-forum.com/u/yashgt)\
**Post date:** [August 27, 2012, 2:01pm UTC](https://www.ruby-forum.com/t/index-directive-not-taking-effect-in-case-of-alias/222382/2 "2012-08-27T14:01:55Z")

</div>

You could also define index inside the server block, outside the  
location  
block:

server {  
index index.php;

location …

location …  
}

Posted at Nginx Forum:

> **[Re: index directive not taking effect in case of alias](https://forum.nginx.org/read.php?2,229985,230102#msg-230102)**
>
> I would like the pnp4nagios app to be accessed as: http://server/pnp4nagios/. With this URL it gives a 403 Forbidden error. It works when I give: http://server/pnp4nagios/index.php. What might be wrong? Here is the pnp4nagios location config:...

---

<div class="post-metadata">

**Author:** ![yashgt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yashgt](https://www.ruby-forum.com/u/yashgt)\
**Post date:** [August 27, 2012, 2:05pm UTC](https://www.ruby-forum.com/t/index-directive-not-taking-effect-in-case-of-alias/222382/3 "2012-08-27T14:05:08Z")

</div>

Hello!

On Wed, Aug 22, 2012 at 07:07:42AM -0400, yashgt wrote:

> I would like the pnp4nagios app to be accessed as:  
> [http://server/pnp4nagios/](http://server/pnp4nagios/). With this URL it gives a 403 Forbidden error. It  
> works when I give: [http://server/pnp4nagios/index.php](http://server/pnp4nagios/index.php).  
> What might be wrong?
> 
> Here is the pnp4nagios location config:
> 
> ```
> location ~ /pnp4nagios {
> alias $pnp4nagiosbase/share;
> 
> ```

- 

```
location ~ /pnp4nagios {

```

- 

```
location /pnp4nagios {

```

[…]

Maxim D.
