mirror of
https://github.com/discourse/discourse.git
synced 2025-09-10 21:01:33 +08:00
FEATURE: add a way to map arbitrary urls to a topic, post, or category. Useful for sites that have migrated to Discourse and want to redirect from their old site to Discourse with 301 redirects.
This commit is contained in:
parent
8a6c4234fc
commit
14890a6002
9 changed files with 156 additions and 0 deletions
12
app/controllers/permalinks_controller.rb
Normal file
12
app/controllers/permalinks_controller.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class PermalinksController < ApplicationController
|
||||
skip_before_filter :check_xhr, :preload_json
|
||||
|
||||
def show
|
||||
permalink = Permalink.find_by_url(params[:url])
|
||||
if permalink && permalink.target_url
|
||||
redirect_to permalink.target_url, status: :moved_permanently
|
||||
else
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue