Jump to content

Redirection to maintain SEO credit


davo
 Share

Recommended Posts

Like a lot of people, processwire sites I work on started life in other CMSs like Joomla and Wordpress where they've outgrown the scope of CMS with clients asking for more and more bespoke content. For some of my clients, SEO is a big issue as we've spent year's building up these strong pages.

When creating a new site in processwire the url structure can be vastly different from the original site meaning search engines will mostly have broken links damaging the sites ranking. There's many other techniques to achieve this such as using htaccess but that can become very complicated and way to complex for most clients to manage themselves so I use this technique.

I create a template with two fields, title and redirect. 'redirect' is a page select field. The title must match the url of the old page and the redirect is as you might guess, the page to redirect to.

You can build up the url with parent and child pages to  match the old site url.

My template looks like this:

<?php
	/*
	 * Template: redirectPage
	 *
	 * Used to redirect URL adress to other page with 301 HTTP code
	 */
	$session->redirect($page->redirect->url);

?>

The 301 let's google know that the page has permanently moved. See here for their explanation.

Then, just work your way through your pages and URLS.

See this little screenomatic for a visual.

Screenomatic

youtube

  • Like 2
Link to comment
Share on other sites

Not a lot had I have found it first!

The only advantage my method has for me, is the current site I'm doing has over 150 important links for redirection and I don't intend to do each of those myself. I share the content management jobs with the client's staff. My method means i can hand this job over to them without giving them access to other modules I wouldn't normally.

Unless you can restrict user access to a per module basis?

Hey davo - nice work!

I am curious - I think I might be missing something - what advantage does this have over apeisa's Redirects module?

http://modules.processwire.com/modules/process-redirects/

  • Like 1
Link to comment
Share on other sites

It is definitely possible to set up a permission for modules. Actually, that might be a nice addition to the Redirects module. It's simply a matter of setting the permission required in the module config and then giving a role that permission. 

I was just going to suggest the batcher module. Here is how it is implemented:

https://github.com/wanze/ProcessBatcher/blob/master/ProcessBatcher.module#L58

Then typically the module adds that permission when it installs.

EDIT Perhaps you should make those changes to Redirects and submit a Pull Request!

Edited by adrian
  • Like 2
Link to comment
Share on other sites

It is definitely possible to set up a permission for modules. Actually, that might be a nice addition to the Redirects module. It's simply a matter of setting the permission required in the module config and then giving a role that permission. 

I was just going to suggest the batcher module. Here is how it is implemented:

https://github.com/wanze/ProcessBatcher/blob/master/ProcessBatcher.module#L58

Then typically the module adds that permission when it installs.

EDIT Perhaps you should make those changes to Redirects and submit a Pull Request!

So I installed the redirect module but looking into the config I see this:

class ProcessRedirects extends Process {

	public static function getModuleInfo() {
		return array(
			'title' => 'Redirects',
			'summary' => 'Manage redirects',
			'href' => 'http://processwire.com/talk/index.php/topic,171.0.html',
			'version' => 100,
			'permanent' => false,
			'autoload' => true,
			'singular' => true,
			'permission' => 'redirects-admin'
		);
	}

So I'm thinking the permission is already there? So I create a new permission page called redirects-admin and added that to a role which seemed to make the  module available to users with that role.

So now I'm confused, what should I add to the repository for a pull request?

Link to comment
Share on other sites

So I'm thinking the permission is already there? So I create a new permission page called redirects-admin and added that to a role which seemed to make the  module available to users with that role.

Sorry, my mistake - I was running an older version of the module - looks like apeisa added that functionality back in April:

https://github.com/apeisa/ProcessRedirects/commit/59c9504defde15a2080cc24e9ac7504739926167

So really nothing needs to be done. He could have automatically had the module create that permission, but not really that important.

Anyway you should have no problem now allowing users access to create redirects.

Link to comment
Share on other sites

Which leaves me desperately trying to find a reason why someone would use my method over the module... and the oooonly thing I can think of is my method uses  the page field to create the new redirect which means if the new url should change then my redirection would change with it stopping the link from breaking. That's preferable for me.

Could it be added to the module as an option instead of the freetext url redirect?

Would anyone else want this?

Link to comment
Share on other sites

This is all very interesting as the site that I am currently building will need a boatload of redirects to new paths. Im sorry for jumping in the middle of this but is there any way to combine batcher with the redirect module so that an entire site could be migrated?

Link to comment
Share on other sites

Without knowing what redirects are needed, it's hard to now the best way to help you out here.

You might be better off with a modrewrite rule if it's a standard pattern that you could match so you can rewrite all links with one rule, or a collection of rules that handle your different scenarios.

Otherwise, you might be able to write a small script to batch create redirect entries for this module based on a regex.

  • Like 2
Link to comment
Share on other sites

Another way could be to use google webmasters. I believe it can create a spreadsheet of all your indexed pages. The copy that into the redirects module and start adding target links.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...