# Installation: Too many redirects

**URL:** <https://discourse.getcockpit.com/t/installation-too-many-redirects/1283>\
**Category:** Support\
**Created:** [March 21, 2020, 11:38am UTC](https://discourse.getcockpit.com/t/installation-too-many-redirects/1283 "2020-03-21T11:38:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vulcan](https://avatars.discourse-cdn.com/v4/letter/v/a3d4f5/32.png) [@vulcan](https://discourse.getcockpit.com/u/vulcan)\
**Post date:** [March 21, 2020, 11:38am UTC](https://discourse.getcockpit.com/t/installation-too-many-redirects/1283/1 "2020-03-21T11:38:24Z")

</div>

Hi all,

I am just trying to setup Cockpit on a subdomain (shared host on Strato). The subdomain currently support no https, but I hope that´s not an issue.

What I´ve done so far:

- Copied Cockpit into /cms on the document root
- Point the subdomain to /cms
- Created defines.php with this content:

> \<?php

> define(‘COCKPIT\_BASE\_URL’, ‘/’);

> define(‘COCKPIT\_BASE\_ROUTE’, ‘/’);  
> define(‘COCKPIT\_DOCS\_ROOT’, dirname( **DIR** ));

First time start seems to work. I could login in as admin/admin.

But when I open [cms.myurl.com](http://cms.myurl.com) it redirects multiple times to [cms.myurl.com/auth/login](http://cms.myurl.com/auth/login) and reports error ERR\_TOO\_MANY\_REDIRECTS.

I added a debug script to bootstrap.php to display some constants:

[COCKPIT\_ADMIN] =\> 1\<  
[COCKPIT\_START\_TIME] =\> 1584809491.7669  
[COCKPIT\_CLI] =\>  
[COCKPIT\_BASE\_URL] =\> /  
[COCKPIT\_BASE\_ROUTE] =\> /  
[COCKPIT\_DOCS\_ROOT] =\> /mnt/web223/b3/49/xxxxxxxx/htdocs  
[COCKPIT\_DIR] =\> /mnt/web223/b3/49/xxxxxxxx/htdocs/cms  
[COCKPIT\_ENV\_ROOT] =\> /mnt/web223/b3/49/xxxxxxxx/htdocs/cms  
[COCKPIT\_API\_REQUEST] =\> 0  
[COCKPIT\_SITE\_DIR] =\> /mnt/web223/b3/49/xxxxxxxx/htdocs  
[COCKPIT\_CONFIG\_DIR] =\> /mnt/web223/b3/49/xxxxxxxx/htdocs/cms/config  
[COCKPIT\_STORAGE\_FOLDER] =\> /mnt/web223/b3/49/xxxxxxxx/htdocs/cms/storage  
[COCKPIT\_ADMIN\_CP] =\> 1  
[COCKPIT\_PUBLIC\_STORAGE\_FOLDER] =\> /mnt/web223/b3/49/xxxxxxxx/htdocs/cms/storage  
[COCKPIT\_CONFIG\_PATH] =\> /mnt/web223/b3/49/xxxxxxxx/htdocs/cms/config/config.yaml

Currently I am stuck. Can anyone help, please?  
Thanks.

---

<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:** [March 21, 2020, 4:37pm UTC](https://discourse.getcockpit.com/t/installation-too-many-redirects/1283/2 "2020-03-21T16:37:00Z")

</div>

I’m not 100% sure, but I think `COCKPIT_SITE_DIR` should point to `/htdocs/cms`, too. I only had one Cockpit project on a strato host and I used cockpit in a subdirecotry without a sub domain. So `example.com/cockpit` worked with just defining

```php
<?php
// strato environment, root is in subdir, but domain points to root/subdir
// cockpit is in root/subdir/cockpit
if (!defined('COCKPIT_BASE_URL')) define('COCKPIT_BASE_URL', '/' . basename( __DIR__ ));
if (!defined('COCKPIT_BASE_ROUTE')) define('COCKPIT_BASE_ROUTE', COCKPIT_BASE_URL);
if (!defined('COCKPIT_DOCS_ROOT')) define('COCKPIT_DOCS_ROOT', dirname( __DIR__ ));

```

Maybe you have to set `RewriteBase /` in `.htaccess`, too.

See also this thread

> [@What are your hosting providers and how do you like them?](https://discourse.getcockpit.com/t/what-are-your-hosting-providers-and-how-do-you-like-them/1161):
>
> Hello, I’m looking for a hosting provider that plays well with Cockpit. Especially with Cockpit in a subdirectory and a Website/PWA in the root. I’d appreciate any recommendations before just trying out random ones wink Thanks in advance

Oh, and if you are forced to use strato, don’t forget to add a `.htaccess` file in your public root directory that denies all or redirects to your main domain. Otherwise `customer_id.swh.strato-hosting.eu` exposes all files above `/htdocs` - and you made your customer id public in your screenshot.

> [@vulcan](#):
>
> The subdomain currently support no https, but I hope that´s not an issue.

Cockpit should work fine without https, but in general it is a big issue 😉

---

<div class="post-metadata">

**Author:** ![vulcan](https://avatars.discourse-cdn.com/v4/letter/v/a3d4f5/32.png) [@vulcan](https://discourse.getcockpit.com/u/vulcan)\
**Post date:** [March 21, 2020, 5:23pm UTC](https://discourse.getcockpit.com/t/installation-too-many-redirects/1283/3 "2020-03-21T17:23:05Z")

</div>

Thanks for the reply and for pointing out the posted id. I edited my post.

Now I pointed COCKPIT\_SITE\_DIR to /htdocs/cms but it results in the same problem.  
I also commented the “RewriteBase” back in in the shipped .htaccess file without success.

> Oh, and if you are forced to use strato, don’t forget to add a `.htaccess` file in your public root directory that denies all or redirects to your main domain

So I need to add the .htacces file to the web page folder, right? For example:  
/mnt/web223/b3/49/xxxxxxxx/htdocs/webpage/.htaccess

Maybe I will place cockpit in a subfolder of the webpage if I don´t find a solution. That domain contain a valid SSL certificate as well.

---

<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:** [March 22, 2020, 10:56pm UTC](https://discourse.getcockpit.com/t/installation-too-many-redirects/1283/4 "2020-03-22T22:56:56Z")

</div>

I’m sorry, that it didn’t work. I was able to run it for my use case once and if I ever have to touch strato again, I’ll grab my notes from the last project and try to fiddle with it.

Maybe `RewriteBase /cms` works…

Or maybe @serjoscha87 has a hint? He mentioned, that his agency has a huge internal strato issue wiki.

> [@vulcan](#):
>
> So I need to add the .htacces file to the web page folder, right? For example:  
> /mnt/web223/b3/49/xxxxxxxx/htdocs/webpage/.htaccess

No! Strato is ugly, bad, slow and insecure: `/mnt/web223/b3/49/xxxxxxxx/htdocs/.htaccess`. It looks, like you could store secret files in this directory, because their user interface forces you to point all your domains to sub directories, but their id url exposes that parent directory. Before I posted my last answer, I did a quick test and I was able to access your test setup at `customer_id.swh.strato-hosting.eu/cms` and id redirected me to `customer_id.swh.strato-hosting.eu/auth/login`.

Sorry for the flaming, but everytime I worked with this hoster, I had a ton of problems and the easiest solution was to create a dns entry to a different hoster.

---

<div class="post-metadata">

**Author:** ![serjoscha87](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/serjoscha87/32/151_2.png) [@serjoscha87](https://discourse.getcockpit.com/u/serjoscha87)\
**Post date:** [March 29, 2020, 12:51pm UTC](https://discourse.getcockpit.com/t/installation-too-many-redirects/1283/5 "2020-03-29T12:51:55Z")

</div>

did not read all the stuff in this post yet, just saw there is a strato problem (strato s\*\*\*\* in so many aspects - I often had hard times messing around with this s\*\*\*\* provider… 😠 😠 😠 )

try putting

```
// STRATO FIX
$_SERVER['DOCUMENT_ROOT'] = rtrim($_SERVER['PHPRC'], DIRECTORY_SEPARATOR);
// ------------

```

to the very top of the index.php (located in the document root)

somehow strato sets up the server env vars another way just every other provider does, leading us to some strange problems. This line above should make cockpit being able to deal with the strato env condition.

\*edit: I absolute agree with raffaelj and the things he is saying about strato… This provider made me go completely mad… not just once
