# Can't access api

**URL:** <https://discourse.getcockpit.com/t/cant-access-api/221>\
**Category:** Uncategorized\
**Created:** [August 23, 2018, 10:49pm UTC](https://discourse.getcockpit.com/t/cant-access-api/221 "2018-08-23T22:49:00Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [September 7, 2018, 4:25pm UTC](https://discourse.getcockpit.com/t/cant-access-api/221/4 "2018-09-07T16:25:47Z")

</div>

I collected a few defines from tests on different hosts before. Maybe, there is one for you. If you nest your cockpit deeper, you may adjust some paths to something like `basename(basename( __DIR__ ))`…

Setup (I used PHP and not the API, but I tested the API for the forms endpoint):

```auto
- cockpit/... --> Backend
- index.php --> Frontend
- .htaccess
- ...

```

## strato (shared host):

subdomain points to `/dir`

Frontend:

```php
define('BASE_URL', '/' . basename( __DIR__ ));
define('BASE_ROUTE', '/' . basename( __DIR__ ));
$options['route'] = preg_replace('#'.preg_quote(BASE_URL, '#').'#', '', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), 1);

```

Backend:

```php
define('COCKPIT_BASE_URL', '/' . basename( __DIR__ ));
define('COCKPIT_BASE_ROUTE', '/' . basename( __DIR__ ));
define('COCKPIT_DOCS_ROOT', dirname( __DIR__ ));

```

## Uberspace6, Uberspace7 (shared host)

works out of the box if using `var/www/virtual/$USER/html`

If using subomain `var/www/virtual/$USER/blog.example.com`:

Frontend: `.htaccess` needs `RewriteBase /`

Backend: `.htaccess` needs `RewriteBase /cockpit`

---

_[View the full topic](https://discourse.getcockpit.com/t/cant-access-api/221)._
