# Slim 4 on NGINX with a specific location directive

**URL:** <https://discourse.slimframework.com/t/slim-4-on-nginx-with-a-specific-location-directive/5393>\
**Category:** Questions\
**Created:** [October 1, 2022, 7:34pm UTC](https://discourse.slimframework.com/t/slim-4-on-nginx-with-a-specific-location-directive/5393 "2022-10-01T19:34:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaminda](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@chaminda](https://discourse.slimframework.com/u/chaminda)\
**Post date:** [October 1, 2022, 7:34pm UTC](https://discourse.slimframework.com/t/slim-4-on-nginx-with-a-specific-location-directive/5393/1 "2022-10-01T19:34:13Z")

</div>

I have Slim v4 framework installed with nginx/1.22.0 and php-fpm-8.1.9 on RHEL8. Here is the / location block of current nginx.conf that works fine.

```auto
  location / {
     root /path/to/html/slim;
     try_files $uri /index.php$is_args$args;
  }

```

Instead of using `location /`, I’d like to use a different location for slim, so that / can be used to host another website. I tried below configuration, but slim gives me **404 Not Found** with `Slim\Exception\HttpNotFoundException`. Please help me to figure out a way. Thank you!

```auto
  root /path/to/html;

  location /slim {
     try_files $uri /index.php$is_args$args;
  }

  location / {
    try_files $uri =404;
  }

```

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [October 4, 2022, 3:12pm UTC](https://discourse.slimframework.com/t/slim-4-on-nginx-with-a-specific-location-directive/5393/2 "2022-10-04T15:12:26Z")

</div>

You may take a look into the documentation, see [Nginx configuration](https://www.slimframework.com/docs/v4/start/web-servers.html#nginx-configuration).

If you run your Slim app not directly under the document-root, you may also have to set the public URI basePath: `$app->setBasePath('/different/path');`
