# Trailing slash and subfolder setup

**URL:** https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403
**Category:** Support
**Created:** [September 22, 2017, 11:14am UTC](https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403 "2017-09-22T11:14:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [September 22, 2017, 11:14am UTC](https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403/1 "2017-09-22T11:14:36Z")

</div>

Hi, I found that current configuration  
_a) sensible to end slash at user’s request_ and  
_b) returns incorrect location._  
B may cause a problem for environments, where two web servers running at the same hardware, for example Drupal + Discourse behind the proxy. Incorrect URL-requests from users may be redirected to inexistent Drupal pages, and it is hard to handle all those requests by proxies config regexp.  
To check if your configuration is ok, run two requests:

```
curl -v http://example.com/forum/c/
curl -v http://example.com/forum/c

```

Both requests should work, they redirect to forum categories. If not, make the first change to the configuration at the topic:  
a) add a slash at the end of your custom forum definition, i.e

```
location /forum/ {

```

Then check curl output, line ‘Location’. It should contain ‘forum’ word:

```
< Location: http://example.com/forum/categories

```

Wrong configuration returns incorrect URL:

```
< Location: http://example.com/categories

```

This can be resolved by adding proxy\_redirect to discourse upstream in /etc/nginx/conf.d/discourse.conf inside docker. Because this file is prepared during image bootstrap or rebuild, you need to add the following code to ‘run’ section of containers/app.yml:

```
- exec:
     cmd:
       - sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/example.com\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf
       - sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/example.com\/forum\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf
       - sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/example.com\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf

```

where the definition line contains your server base\_url and subfolder, it looks like:

```
proxy_redirect http://example.com/ /forum/;

```

Sorry for sed, I am not a familiar to yaml syntax 😕, appreciated to any remarks.

Current configuration free me of handling incorrect requests went to Discourse.

You may follow my post concerning Drupal SSO with Discourse behind a proxy [here](https://meta.discourse.org/t/trouble-connecting-drupal-and-discourse/34168/7). Welcome for any suggestions on the subject.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 20, 2017, 6:20am UTC](https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403/2 "2017-11-20T06:20:02Z")

</div>

I am not following are any changes needed to: [Serve Discourse from a subfolder (path prefix) instead of a subdomain](https://meta.discourse.org/t/subfolder-support-with-docker/30507) ? What changes do you recommend be made to the demo template there?

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [July 2, 2018, 12:25pm UTC](https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403/3 "2018-07-02T12:25:14Z")

</div>

Hi @sam, sorry for my late response. I created the topic just for check purposes for those people who decided to install forum from subfolder. No need to make changes in template. Thanks!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 2, 2018, 10:01pm UTC](https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403/4 "2018-07-02T22:01:30Z")

</div>


