This sounds like a good candidate for an extension. The basic strategy
would be to override either SiteController.show_page or Page.find_by_url
to search for a page that has the passed legacy URL (you’ll need to add
a field in the database), in the case that the requested URL was not
found. If a page is found, do a Permanent redirection (301 IIRC) to the
new URL. If it isn’t found, pass through the FileNotFoundPage or
exception.
I wouldn’t mind working on that if there were enough interest. Does
anyone
else need this? Also can someone help me to set the blog page of my
site to
use a subdomain?
I wouldn’t mind working on that if there were enough interest. Does anyone
else need this? Also can someone help me to set the blog page of my site to
use a subdomain?
Hi Chris,
Might be able to help with your second question but I’m not sure I
understand it fully. What do you mean by:
Also can someone help me to set the blog page of my site to
use a subdomain?
If you mean can it run like the way my Radiant site is running at http://t-engine.onghu.com instead of htttp://www.onghu.com/ then I can
help you with it.
I ended up leaving the blog on typo and its running at blog.randomutterings.com. The rest of the site is now on radiant at www.randomutterings.com. Can anyone tell me the simplest way to do a
301
redirect in Radiant? I have 3 or 4 articles that moved to the blog
subdomain and I would like to create pages in Radiant with their old
urls
and redirect them to the new ones.
I did something similar for Redken… essentially create a new Page type
called RedirectPage that does the redirection for you:
class RedirectPage < Page
def process(request, response)
response.redirect(part(:body).content, “301 Moved Permanently”)
end
end
Then fill in the URL in the “body” part of the page and set the page
type to “Redirect”. Of course, this will need to be in an extension.
(Also, I’m not 100% positive on the syntax above, be sure to check.)
I ended up leaving the blog on typo and its running at blog.randomutterings.com. The rest of the site is now on radiant at www.randomutterings.com. Can anyone tell me the simplest way to do a
301
redirect in Radiant? I have 3 or 4 articles that moved to the blog
subdomain and I would like to create pages in Radiant with their old
urls
and redirect them to the new ones.
You’ll need to make an extension, first, put the page class in the
extension under app/models, and then “mention” it in the activate method
of your extension class, like so:
class RedirectExtension < Radiant::Extension
#…
def activate
RedirectPage
end
end
At some point, I’d like to have extensions automatically load page
classes, but that may be a feature for the next release.
This is great stuff guys, thanks. I have it all working but it
redirects
“302 Found” even if I use the following.
response.redirect(part(:body).content, “301 Moved Permanently”
I’ve tried googling for answers but all I can find on redirecting 301 in
ruby is to use redirect_to which is not available in the model. Any
suggestions?
I’ve got it built but its only doing 302 redirects until I figure out
how to
pass a status into response.redirect but I went ahead and released it
anyway.
I’m open to opinions and suggestions on the code and also writing a test
for
it. You can see my attempts in the source.