Skip to content

A platform for community discussion. Free, open, simple.

ensure correct '/'s for relative_url_root in route file

Blake Erickson0337a8f6d5c4
diff --git a/config/discourse_defaults.conf b/config/discourse_defaults.conf
index 6e3cf55ed07..b267161d3c6 100644
--- a/config/discourse_defaults.conf
+++ b/config/discourse_defaults.conf
@@ -151,7 +151,7 @@ connection_reaper_max_age = 600
# set to relative URL (for subdirectory hosting)
# IMPORTANT: path must not include a trailing /
# EG: /forum
-relative_url_root =
+relative_url_root = /forum
# increasing this number will increase redis memory use
# this ensures backlog (ability of channels to catch up are capped)
diff --git a/config/routes.rb b/config/routes.rb
index 2c603b3ac26..d20ecaafce7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -10,7 +10,7 @@ USERNAME_ROUTE_FORMAT = /[\w.\-]+?/ unless defined? USERNAME_ROUTE_FORMAT
BACKUP_ROUTE_FORMAT = /.+\.(sql\.gz|tar\.gz|tgz)/i unless defined? BACKUP_ROUTE_FORMAT
Discourse::Application.routes.draw do
- relative_url_root = (defined?(Rails.configuration.relative_url_root) && Rails.configuration.relative_url_root) ? Rails.configuration.relative_url_root : ''
+ relative_url_root = (defined?(Rails.configuration.relative_url_root) && Rails.configuration.relative_url_root) ? Rails.configuration.relative_url_root + '/' : '/'
match "/404", to: "exceptions#not_found", via: [:get, :post]
get "/404-body" => "exceptions#not_found_body"
@@ -550,7 +550,7 @@ Discourse::Application.routes.draw do
get "/badges/:id(/:slug)" => "badges#show"
resources :user_badges, only: [:index, :create, :destroy]
- get '/c', to: redirect('/' + relative_url_root + 'categories')
+ get '/c', to: redirect(relative_url_root + 'categories')
resources :categories, except: :show
post "category/:category_id/move" => "categories#move"
@@ -732,7 +732,7 @@ Discourse::Application.routes.draw do
# current site before updating to a new Service Worker.
# Support the old Service Worker path to avoid routing error filling up the
# logs.
- get "/service-worker.js" => redirect('/' + relative_url_root + service_worker_asset), format: :js
+ get "/service-worker.js" => redirect(relative_url_root + service_worker_asset), format: :js
get service_worker_asset => "static#service_worker_asset", format: :js
end