HTTP Redirects for Redirected Pages
If a page isn't found, but there is a page that redirects for it, don't show a 404!
This commit is contained in:
parent
0943b7e510
commit
a2b1c7e66c
|
@ -229,9 +229,17 @@ class WikiController < ApplicationController
|
||||||
@page_name ||= 'HomePage'
|
@page_name ||= 'HomePage'
|
||||||
@page ||= wiki.read_page(@web_name, @page_name)
|
@page ||= wiki.read_page(@web_name, @page_name)
|
||||||
@link_mode ||= :publish
|
@link_mode ||= :publish
|
||||||
render(:text => "Page '#{@page_name}' not found", :status => 404, :layout => 'error') and return unless @page
|
if @page
|
||||||
|
|
||||||
@renderer = PageRenderer.new(@page.revisions.last)
|
@renderer = PageRenderer.new(@page.revisions.last)
|
||||||
|
else
|
||||||
|
real_page = WikiReference.page_that_redirects_for(@web, @page_name)
|
||||||
|
if real_page
|
||||||
|
flash[:info] = "Redirected from \"#{@page_name}\"."
|
||||||
|
redirect_to :web => @web_name, :action => 'published', :id => real_page
|
||||||
|
else
|
||||||
|
render(:text => "Page '#{@page_name}' not found", :status => 404, :layout => 'error')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def revision
|
||||||
|
@ -311,7 +319,13 @@ class WikiController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not @page_name.nil? and @page_name.is_utf8? and not @page_name.empty?
|
if not @page_name.nil? and @page_name.is_utf8? and not @page_name.empty?
|
||||||
|
real_page = WikiReference.page_that_redirects_for(@web, @page_name)
|
||||||
|
if real_page
|
||||||
|
flash[:info] = "Redirected from \"#{@page_name}\"."
|
||||||
|
redirect_to :web => @web_name, :action => 'show', :id => real_page
|
||||||
|
else
|
||||||
redirect_to :web => @web_name, :action => 'new', :id => @page_name
|
redirect_to :web => @web_name, :action => 'new', :id => @page_name
|
||||||
|
end
|
||||||
else
|
else
|
||||||
render :text => 'Page name is not specified', :status => 404, :layout => 'error'
|
render :text => 'Page name is not specified', :status => 404, :layout => 'error'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue