Although this site is new, I’m slowly incorporating a series of old, defunct projects into it. I already have a good number of posts/articles written on various topics (Web Design, Education, Gaming), and some of them have some decent search engine visibility.
Rather than let these articles languish forever in obscurity, it seems best to add them to the archives of this site. This has the added benefit of driving some search engine traffic to the site, and helping it get indexed by the search engines much faster.
Using a 301 Redirect, I can automatically direct people to the new location of an article and alert search engines that the article has moved.
You can use some fancy .htaccess editing to redirect a whole site from one domain to another, but this depends on the url structure of the site remaining the same. I can’t guarantee that, and in fact I’m deliberately changing the url structure to better organize the posts into categories and sub-categories. So I need to be able to re-direct the articles on a page-by-page basis.
Post-by-Post 301 Redirect in WordPress
For WordPress, I found a great plug-in to do this – Angsuman’s Permanent Redirect.
Like most WordPress plug-ins, installation is simple. Download and extract.
Usage is equally simple. For each post that you want to redirect, create a custom field called “redirect.” Enter the new url of the post as the value of the custom field.
That’s it. I’ve already gone through one site, ported over 100+ posts, and set each one to re-direct to its new address at Life of Brian. It took me a few hours, but I think it was time well spent. I’ve already seen a decent amount of search traffic coming to that section of the site, despite the fact that it’s only been live for a few days.
Post-by-Post Redirects in CMS Made Simple
Although WordPress is now my CMS of choice, I designed an older site with CMS Made Simple. I did a hefty amount of customization to the site, and CMSMS gave me a lot of freedom in writing custom extensions to add to the site’s functionality.
For now, I want to rescue all of the posts/articles on the site and store them in the new education portion of Life of Brian. I’m not sure if there was a plug-in available to do this, but I was easily able to enable post-by-post redirects for any content page.
Step One: Create a Blank Template
We’ll be using a the php
header() function to redirect the page, and this should appear before any other output is sent to the user’s browser.
In my old version of CMSMS, I went to Layout -> Templates in the admin section, and clicked on “Add New Template.” I called it redirect. I then deleted everything in the main content area, and entered a single line…
Step Two: Create a User-Defined Tag
A user-defined tag is a snippet of php code that you can insert into the content section of any content page in CMSMS.
Go to Extensions -> User Defined Tags in the Admin area. Then click on “Add User Defined Tag.” I called my tag “redirect” and entered the following php snippet:
header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $params['url']);
Use the Tag to Redirect a Page
Now, we can edit any content page on the site and add a custom redirect.
Navigate through the admin area to the page you want to redirect. Change its template to the “redirect” template we created.
Then, add the following snippet as the first line in the content.
Just add the URL you want to redirect to inside the quotations, and you’re good to go. This calls the user defined tag we created and passes it the URL as a parameter. The tag then outputs the HTTP redirect header, and the user’s browser will seamlessly travel to the new site.
No Comments Yet
You can be the first to comment!