# Moving Discourse to subdirectory caused all uploads to break

**URL:** https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569
**Category:** Support
**Created:** [27.Август.2015 01:32:15 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569 "2015-08-27T01:32:15Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![staticinvocation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/staticinvocation/32/54469_2.png) [@staticinvocation](https://meta.discourse.org/u/staticinvocation)
#### Post date: [27.Август.2015 01:32:15 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/1 "2015-08-27T01:32:15Z")

</div>

I recently bought an EV cert for my domain and I wanted to use it on both my main site and my forum. To solve this, I followed [this guide](https://meta.discourse.org/t/subfolder-support-with-docker/30507) and moved it to a subdirectory using a Varnish configuration.

The only noticeable problem was that this broke all current and new uploads. Existing uploads 404 from nginx, and new uploads fail with no error in sideqik or the error log.

You can view the site here: [https://platinumcheats.net/forum/](https://platinumcheats.net/forum/). It was moved from [http://forum.platinumcheats.net/](http://forum.platinumcheats.net/).

Anyone know what the deal is/how to fix? I understand that subdirectories are now officially supported in Discourse.

---

<div class="post-metadata">

### Author: ![staticinvocation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/staticinvocation/32/54469_2.png) [@staticinvocation](https://meta.discourse.org/u/staticinvocation)
#### Post date: [27.Август.2015 02:16:39 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/2 "2015-08-27T02:16:39Z")

</div>

So poking around in the rails production log, I found this when uploading a file:

```
Started GET "/forum/uploads.json?client_id=xxx&authenticity_token=xxx" for xxx at 2015-08-27 02:15:10 +0000
ActionController::RoutingError (No route matches [GET] "/uploads.json")
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.10/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
Processing by ExceptionsController#not_found as JSON
  Parameters: {"client_id"=>"xxx", "authenticity_token"=>"xxx"}
Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.3ms)

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [27.Август.2015 02:47:31 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/3 "2015-08-27T02:47:31Z")

</div>

Did you check our topics in the howto category on subfolder?

[https://meta.discourse.org/search?q=Subfolder%20category%3Ahowto](https://meta.discourse.org/search?q=Subfolder%20category%3Ahowto)

---

<div class="post-metadata">

### Author: ![staticinvocation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/staticinvocation/32/54469_2.png) [@staticinvocation](https://meta.discourse.org/u/staticinvocation)
#### Post date: [27.Август.2015 02:49:13 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/4 "2015-08-27T02:49:13Z")

</div>

I did. In the OP I stated I followed this howto:

> [@Serve Discourse from a subfolder (path prefix) instead of a subdomain](https://meta.discourse.org/t/subfolder-support-with-docker/30507):
>
> warning Discourse Official Statement about Subfolder setup We support subfolder setups for our hosted customers at the enterprise level and up. Due to heavy technical setup complexity we strongly recommend you do not use this setup unless you are very experienced in custom subfolder setups. It is critical you have a deep understanding of NGINX setup in the Discourse Docker container Secure original IP forwarding using custom headers in the proxy chain Rate limiting in front proxy server I…

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [27.Август.2015 02:56:19 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/5 "2015-08-27T02:56:19Z")

</div>

Yeah looks like the issue is you changed to subfolder after the fact so all your uploads are in the old place. Any advice in this case @neil or @zogstrip?

Maybe we can update the howto so it covers this case as well.

---

<div class="post-metadata">

### Author: ![staticinvocation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/staticinvocation/32/54469_2.png) [@staticinvocation](https://meta.discourse.org/u/staticinvocation)
#### Post date: [27.Август.2015 03:00:19 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/6 "2015-08-27T03:00:19Z")

</div>

Does the howto therefore assume a clean Discourse installation (e.g. not a rebuild)?

---

<div class="post-metadata">

### Author: ![staticinvocation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/staticinvocation/32/54469_2.png) [@staticinvocation](https://meta.discourse.org/u/staticinvocation)
#### Post date: [27.Август.2015 06:28:58 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/7 "2015-08-27T06:28:58Z")

</div>

So I did a fresh install and restored from a backup. Everything is working perfectly now.

---

<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.Август.2015 14:28:45 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/8 "2015-08-27T14:28:45Z")

</div>

I don’t know why new uploads would have been failing…

To fix existing uploads you need to run the remap tool. Something like this:

`bundle exec script/discourse remap '/uploads' '/forum/uploads'`

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [27.Август.2015 19:46:58 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/9 "2015-08-27T19:46:58Z")

</div>

And remap tool is covered in the existing howtos?

---

<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.Август.2015 22:40:56 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/10 "2015-08-27T22:40:56Z")

</div>

Of course it is (because I just added it). The last section of [this post](https://meta.discourse.org/t/subfolder-support-with-docker/30507/1) mentions it.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [02.Ноябрь.2018 20:07:53 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/11 "2018-11-02T20:07:53Z")

</div>



---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [02.Ноябрь.2018 21:23:18 UTC](https://meta.discourse.org/t/moving-discourse-to-subdirectory-caused-all-uploads-to-break/32569/12 "2018-11-02T21:23:18Z")

</div>


