# Trailing slash and subfolder setup

**URL:** <https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403>\
**Category:** Product Support\
**Created:** [22 سبتمبر 2017، 11:14ص UTC](https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403 "2017-09-22T11:14:36Z")\
**Posts on this page:** 1\
**Showing post:** 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:** [22 سبتمبر 2017، 11:14ص 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.

---

_[View the full topic](https://meta.discourse.org/t/trailing-slash-and-subfolder-setup/74403)._
