# Mudando de diretório para subdomínio

**URL:** https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475
**Category:** Self-hosting
**Tags:** subfolder
**Created:** [25 Fevereiro , 2018 16:13 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475 "2018-02-25T16:13:05Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [25 Fevereiro , 2018 16:13 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/1 "2018-02-25T16:13:05Z")

</div>

Olá pessoal,

Para tornar minha configuração menos complicada, conforme o conselho de @codinghorror, e como o Let’s Encrypt agora suporta subdomínios, decidi mover meu Discourse de foo.bar/forum para forum.foo.bar.

O que fiz:

Mudei o nome do domínio no meu app.yml, removi o mapeamento de pasta dos comandos personalizados, depois remapeei foo.bar/forum para forum.foo.bar via discourse remap e, em seguida, rebakei as postagens.

O problema é o seguinte:

Quando abro [https://forum.foo.bar/](https://forum.foo.bar/), ele tenta buscar [https://stylesheets/etc](https://stylesheets/etc), o que faz com que a exibição do fórum quebre e eu não consiga fazer login ou alterar o tema do site.

O que posso fazer para corrigir isso?

Se necessário, aqui está a URL de instalação: [https://forum.legiochristi.com/](https://forum.legiochristi.com/)  
Meu app.yml: [## this is the all-in-one, standalone Discourse Docker container template### - Pastebin.com](https://pastebin.com/pZPw3Ju5)

Qualquer ajuda será apreciada.

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [26 Fevereiro , 2018 08:44 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/2 "2018-02-26T08:44:08Z")

</div>

Okay I managed to log into the admin panel but I can’t seem to change the default theme since it’s dependent on JavaScript to apply.

I also can’t download my latest backup. Is there a way to do this in command line? Either change the theme or download a backup?

Thanks.

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [26 Fevereiro , 2018 08:47 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/3 "2018-02-26T08:47:38Z")

</div>

Have you tried safe-mode?

```plaintext
your.site/safe-mode

```

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [26 Fevereiro , 2018 09:04 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/4 "2018-02-26T09:04:44Z")

</div>

I’m getting this error when I try:

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/a/0a594dea7aa1a8cefb1dd6faa2d789a254f3a16f.png)

Chrome says it’s an invalid redirect.

Is there a way to do it through command line?

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [26 Fevereiro , 2018 10:41 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/5 "2018-02-26T10:41:41Z")

</div>

> [@Ironclad14](#):
>
> Is there a way to do it through command line?

If there is, I’m not aware of it.

Perhaps someone more knowledgeable can comment on that. 🌻

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [26 Fevereiro , 2018 21:02 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/6 "2018-02-26T21:02:31Z")

</div>

Hope so. I’ll probably nuke it and rebuild after I fetch my last backup.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [26 Fevereiro , 2018 21:52 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/7 "2018-02-26T21:52:06Z")

</div>

> [@Ironclad14](#):
>
> What I did:
> 
> Changed the domain name in my app.yml, removed the folder remap from custom commands, then remapped foo.bar/forum to forum.foo.bar via discourse remap, then I rebaked posts.

You did a rebuild too? `./launcher rebuild app`

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [27 Fevereiro , 2018 09:08 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/8 "2018-02-27T09:08:14Z")

</div>

Sure did.

The problem seems to be mostly that it’s trying to fetch [https://stylesheets/file.css](https://stylesheets/file.css) - I have no idea why that happened or how to fix it.

I see the files present in the container but they’re just not called correctly.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [27 Fevereiro , 2018 15:37 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/9 "2018-02-27T15:37:20Z")

</div>

> [@Ironclad14](#):
>
> [https://stylesheets/file.css](https://stylesheets/file.css)

It’s actually using hostname `stylesheets` there? Or what is the actual url?

You haven’t given enough for us to help you. Can you post your container’s yml file after removing credentials?

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [27 Fevereiro , 2018 21:47 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/10 "2018-02-27T21:47:52Z")

</div>

Yes it’s actually using hostname stylesheets.

My app.yml is in the first post.

> <https://pastebin.com/pZPw3Ju5>

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [28 Fevereiro , 2018 03:09 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/11 "2018-02-28T03:09:39Z")

</div>

Your yml file still has the subfolder setting enabled:

```plaintext
DISCOURSE_RELATIVE_URL_ROOT: /

```

Delete that line from the file and rebuild again.

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [28 Fevereiro , 2018 16:48 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/12 "2018-02-28T16:48:09Z")

</div>

amazing

i’ll try that in a sec

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [28 Fevereiro , 2018 18:16 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/13 "2018-02-28T18:16:29Z")

</div>

Okay great that worked! Now the only thing left is to fix all my missing images. I’m getting a 404 on all uploaded avatars and uploaded images. Very odd.

Update:

All images return 404. I rebaked posts, recovered uploads from tombstone, and double-checked whether or not the images exist in the directories.

[https://forum.legiochristi.com/uploads/default/original/1X/b104612ae2622e9ccfbb55197bb4e46059a7c171.png](https://forum.legiochristi.com/uploads/default/original/1X/b104612ae2622e9ccfbb55197bb4e46059a7c171.png)

this is 404

yet it exists both in /var/www/discourse/public/uploads/default/original/1X and in /shared/uploads/default/original/1X (which is symlinked successfully, therefor)

I’m at a loss here.

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [2 Março , 2018 21:47 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/14 "2018-03-02T21:47:23Z")

</div>

Okay I just restored a week old backup and that didn’t help.

I also tried to chmod the uploads directory to 777

Does anyone have any ideas?

---

<div class="post-metadata">

### Author: ![fabraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fabraz/32/180144_2.png) [@fabraz](https://meta.discourse.org/u/fabraz)
#### Post date: [12 Maio , 2020 14:44 UTC](https://meta.discourse.org/t/moving-from-directory-to-subdomain/81475/15 "2020-05-12T14:44:51Z")

</div>

@Ironclad14, estou enfrentando o mesmo problema que você. Fiquei me perguntando se você descobriu como resolver. Se sim, poderia compartilhar?

Obrigado desde já!
