將Redmine架在sub-URI

將Redmine架在sub-URI

參考HowTo Install Redmine in a sub-URIDefect #32318,在config/environment.rb檔案的最底下加上:

ActionController::Base.relative_url_root = RedmineApp::Application.routes.default_scope
Redmine::Utils::relative_url_root = RedmineApp::Application.routes.default_scope

ENV['RAILS_RELATIVE_URL_ROOT'] = "/redmine"
Redmine::Utils::relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']

修改redmine目錄下的config.ru,將:

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
run Rails.application

改成:

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
  run Rails.application
end

參考Bad repository link on search results,在config/additional_environment.rb加上:

config.relative_url_root = '/redmine'

之後再重啟apache2就可以發現地址由https://127.0.0.1變成了https://127.0.0.1/redmine

注:如果只修改config.ru,那麼由rails自動生成的超連結仍會指向舊的網址,導致404 error。

以下是試過沒用的方法:HowTo Install Redmine in a sub-URI, Deploying an app to a sub-URI or subdirectory, How to deploy Rails app on subdomain root with Apache and Passenger

使用此方法後redmine_sidekiq插件的top menu仍會連結到/sidekiq而非/redmine/sidekiq,此問題仍待解決。

undo

config/environment.rb檔案的ENV['RAILS_RELATIVE_URL_ROOT']改成:

ENV['RAILS_RELATIVE_URL_ROOT'] = "/"

config/additional_environment.rbconfig.relative_url_root注釋掉:

# config.relative_url_root = '/redmine'
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值