Changing a page's URL alias breaks existing links. "would be nice" if a module could track and provide 301 redirects

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
mcurry's picture

Currently, when you use a URL path alias to an existing node, and later decide to change the URL alias, the old path 'breaks' - so, if you have an older page that has inbound links from, say, Google search or some web directory, people will get a 404 error - not good for SEO or building traffic, in my experience.

I run a few low-volume (at least for now) sites, and my solution has been to hand-edit the .htaccess file for the site, and add a 301 redirect from the old to the new URL. This is a tedious and error-prone process, so, ideally, it should be handled automatically using some add-in module.

Does anyone know of a module that tracks and maintains URL path changes, and performs automatic 301 redirects to the current correct path? I know about "Search 404" but that's not quite what I'm looking for.

Ideally, a module would keep track of 'hits' on the old URL and, after a configurable time, drop stale paths that haven't been hit (after all, if no one visits an old URL alias in six months, does anyone really care? A manual search or Search 404 module should suffice in that situation.)

Also, I know that you can add a manual URL path alias for the old path(s) using Drupal's built-in modules, but that does not provide 301 "moved permanently" redirection so that the search engines can update their information about the old paths when they update your site.

I think this is a big issue for Drupal and SEO, from a site maintenance standpoint.

Michael Curry
Exodus Development | Drupal and other developer info

Comments

try this modules...

Tobias Maier's picture

I use on all of my sites Path Redirect and Global Redirect.

Global Redirect redirects your visitors coming from node/123 to the corresponding alias - with 301.
Path Redirect allows you to specify your old path and its new target.

unfortunately, no module mentioned tracks if it had to redirect some path. But this is not really needed in my opinion.

Tobias Maier
--
Switch to Firefox! mozilla.com
Steig auf den Firefox um! mozilla-europe.org

Tobias Maier - http://tobiasmaier.info/

Thanks for the pointers. I

mcurry's picture

Thanks for the pointers. I just installed Global Redirect earlier today (thanks to a mention in another posting) - that's a big help.

The Path Redirect module seems like it's promising.. but I'd like to get away from manual maintenance altogether. For example, if I have a site with Urlify installed, simply changing the node title will trigger a url alias change without the editor noticing. Now you've got a broken link. (Yes, this is a weakness in Urlify, and should be addressed in the Urlify module, by not altering an existing path alias when the user changes the title.)

The real issue for me is that established URLs are precious and should not be discarded lightly, and because Drupal makes it trivial to change a URL (nice feature, really) it makes it easy for site content editors to inadvertently create a 404 error, which is why I'd prefer to see an automatic solution... Manual solutions are prone to failure.

In any case, I agree that the two modules you listed are quite helpful. Thanks again!

Michael Curry
Exodus Development | Drupal and other developer info

pathauto solution

greggles's picture

I think you've raised a good point and here's the solution that I've come up with:

If path redirect is installed provide new update option "Make old alias a redirect and create new one". It's not implemented yet, but the idea is there. I think that with some small patches to existing contributed modules your desired situation is achievable.

--
Knaddison Family | mmm Beta Burritos

I agree that would be a nice

mcurry's picture

I agree that would be a nice addition to pathauto - but what about those who never install or use pathauto? (Just asking...)

Is there a way for path_redirect to detect the changes on every node edit? Seems like this functionality ought to be in path_redirect.

Michael Curry
Exodus Development | Drupal and other developer info

.

NikLP's picture

That's what it says in the thread Greggles pointed to...! :)

Sounds good to me. Can we get a fix on this module? I tried having a look but at the moment modules are a bit above my weight.

clarify

greggles's picture

Can we get a fix on which module?

If your question is pathauto then the answer is "in time." If you contribute a patch then I can review commit it, but if it's up to me then I'll do it when I do it... There are other more pressing problems in pathauto at the moment...See http://groups.drupal.org/paths for details.

Greg

--
Knaddison Family | mmm Beta Burritos

pathauto and path redirect

greggles's picture

jjeff found the time to do this so Pathauto now provides an option to "Create new alias. Redirect old alias to new alias". It's pretty awesome.

--
Knaddisons Denver Life | mmm Chipotle Log | The Big Spanish Tour

what speaks against using

Tobias Maier's picture

what speaks against using pathauto instead of urlify?
Pathauto let you decide if you want to let the old path intact or create a new one.

Tobias Maier - http://www.tobiasmaier.info/
--
Switch to Firefox!
Steig auf den Firefox um!
mozilla.com

Tobias Maier - http://tobiasmaier.info/

mcurry's picture

I wanted to be able to specify the URL path alias at the time I created (or edited) the node, and at the time I chose Urlify, pathauto did not offer that, so Urlify appealed to me, even with the obvious drawback mentioned earlier (change node title, urlify blindly changes the path alias... breaking the established URL).

While I appreciate the information about pathauto not blowing away previous path aliases, perhaps a discussion of the relative merits of various automatic path alias modules like pathauto or urlify would be better served by starting another topic focused on which is best from a SEO standpoint (or, if there is already such a thread, let's move this to that thread.)

I stand by my assertion that it would be beneficial, from a SEO standpoint, for Drupal (via an add-in module, if necessary) to track and automatically perform 301 redirects from previous node URL aliases to the current one. That may be a can of worms, but it should be doable, and that's why we have computers - to automate repetitive and error-prone tasks.

Michael Curry
Exodus Development | Drupal and other developer info

Thanks and Danke

funana's picture

Exactly what I was looking for! Got a huge robots.txt to prevent too much duplicate content and it works well but 301 is the way to go.

Dankeschön!

__

SEO Tips For Successful Drupal Sites
__
Cape Verde News & Community
My Info Collection

Thanks for the tip

josiahdajo's picture

These modules are incredibly useful, thanks for sharing.

Chx recently wrote a patch

ChrisKennedy's picture

Chx recently wrote a patch to path.module that includes this feature: http://drupal.org/node/106094

Sweet!

mcurry's picture

Man, if Drupal 6 has this feature built in, that would be awesome! From what I read, that patch is for D6, not 4.x or 5, correct?

Michael Curry
Exodus Development | Drupal and other developer info

Cool

magstudio's picture

While I appreciate the information about pathauto not blowing away previous path aliases, perhaps a discussion of the relative merits of various automatic path alias modules like pathauto or urlify would be better served by starting another topic focused on which is best from a SEO standpoint (or, if there is already such a thread, let's move this to that thread.)

Rohit kapur
Offshore software Development /Outsourcing software Development

IMO...

NikLP's picture

...pathauto is practically a core module (it will likely never be core). This is the module of choice for this task, no question. Little point debating it really... :)

pathauto vs. urlify

greggles's picture

I actually think there are different purposes to the two modules.

Originally I found http://www.cmsproducer.com/urlify-drupal-pathauto-module-alias-title which argues that urlify is far better. I think both are good modules for different situations. See http://knaddison.com/technology/pathauto-and-urlify for details on which situations one makes more sense.

--
Knaddisons Denver Life | mmm Chipotle Log | The Big Spanish Tour

related question: Is there a

SamRose's picture

related question:

Is there a module or solution that allows to map redirects from a non-drupal site to a drupal site/

Sam Rose
Social Synergy
Blog

redirect/URLs modules

Z2222's picture

I don't think there is a Drupal module for it, but if there is a pattern to the old site's URLs you can use mod_rewrite to send 301 redirects to the new URLs... or use Pathauto Module rules to recreate the old URLs automatically by giving different sections of the site different content types or taxonomy.

path redirect

greggles's picture

Path redirect can do this. You can redirect from any url to a new drupal url.

--
Knaddisons Denver Life | mmm Chipotle Log | The Big Spanish Tour

Search404 module can remedy broken URLs

cmsproducer's picture

The Search404 module can be use to point users to a page that has changed it's URL or at east provide a search result of the closest documents with content that matches the clean URL keywords.

In my case, I have configured clean URLs to do a Drupal search using the keywords in the URL, and if only one result is available, redirect to that page. This ensures that if I change the clean URL of a page because of a typo or any other reason, the module can provide useful information to the visitor by doing a search of existing relevant documents.

Granted, this is a lazy/sloppy admin's alternative o running a tight ship with 301 headers etc, but it gets the job done. I have even started using it when I am unable to decide the best document to refer to when writing comments on other sites that I sometimes cook up a URL with keywords in it. For instance, you can read more about my ideas on Drupal configuration and SEO at: http://cmsproducer.com/seo-301-redirects-search-404-drupal

There is no existent page with that URL, but if you click on it, the site will give you a list of the closest matching documents


iDonny Productions: Web CMS and UI/UX Design, Development & Web Standards

Well...

NikLP's picture

I have to be honest, I use s404 and I'm less than pleased with its performance. Every 404 the site generates incurs a DB query, which is pretty wasteful. The real killer for me is that the search terms are rarely useful.

I know that sounds a bit weird, as obviously it's a nice usability feature, but customerror.module allows a custom 404 page, and I'm thinking of creating one for 404 instead of using search404. There I could include the search form, and probably pre-populate the form with some search terms.

The search404 module often gives me search results for stuff that just isn't there, because the path just doesn't relate specifically enough to the content. For instance, the node "/blog/my-drupal-article" might well contain the words "my drupal article", but does not contain the word blog. This means the search doesn't catch that article, so you get no results. Effectively, this query is just trash.

My vote goes to customerror. Other than that, this issue is fixed in path_redirect.

Web Development in Nottingham, UK by Kineta Systems

You have a point, but search404 does let you ignore words

mlncn's picture

You can tell search404 to ignore words taken from the path in its queries, so if you manually tell it to exclude blog and event and quote or whatever else you may have pathauto creating for you, it will start to find nodes again.

benjamin, Agaric Design Collective

benjamin, agaric

Search 404 AND Path Redirect

PRFB's picture

Search 404 alone was somewhat OK for me as a remedy for changed page names -- for users who are both human and diligent. It's also helpful for people who play with URLs to see what's there.

Where Path Redirect rocks my world is ...

  • for Google, who you really should permanent-redirect to the correct page
  • for "lazy" users who may tend to "wander off" if they see Search 404 rather than the results they want
  • for me, when I tweak the titles of nodes, and greggle's Path Redirect - Path Auto integration keeps me from losing people

I agree that Search 404 isn't perfect, but the results are decent enough and I like that it puts the user on a page that has a search box first and foremost, with the "added bonus" of potentially useful results below. So far it doesn't happen often enough that performance is an issue.


CruiseSavvy.com
: cruise information - cruise ship pictures - share your story

yes there is an answer

hal2's picture

solution that allows to map redirects from a non-drupal site to a drupal site...

you an use:
htacccess
php
meta headers
javascript
SSI

but you have to set it up manually, if you want to map from a non-drupal site, that is if that site doesn't have a redirect feature itself.

I am amazed

Aleet's picture

I always assumed URL Alias not just changes aliases but also redirect old alias to new one. To me that would be an obvious and critical feature for a dynamic website that supposedly could be managed by non-techs. But now that I have client who likes tweaking his aliases, I found otherwise and feel humbled for not knowing this all this time. It's like finding out your fancy car runs on foot power, like Fred Flinstones'. After changing alias, I not only have to redirect the old alias but I have to put new code in htaccess to 301 it.

Redirect modules work fine for this now

Kristen Pol's picture

I noticed a lot of old posts, so perhaps you weren't finding the information you need. If you install globalredirect and path_redirect modules, then go to your pathauto settings (in the general fieldset), you will see the update action options. Once path_redirect is enabled, choose the "make new alias, redirect from old alias" option (the 4th one). No need to mess with the .htaccess file.

But, yes, agreed, that it's is disconcerting that when you enable pathauto that this redirect functionality isn't just built-in. Perhaps these will be rolled into Drupal 7... that would be nice.

Good luck,
Kristen
http://kristen.org

Thank you Kristen. I made

Aleet's picture

Thank you Kristen. I made the change. But this is strictly for pathauto, correct? If changed URL in URL Aliases pageadmin/build/path/list and old aliases is not redirected until you use path_redirect.

By the way, I always wondered if Path Auto has the ability to bulk update existing aliases.Can it do that?

There is a checkbox for "Bulk generate aliases for nodes that are not aliased" which sounds like it is only for nodes that have never been aliased. And my site has come along too far to risk testing this feature and possibly end up with a whole bunch of 404's.

Aliases and bulk update

Kristen Pol's picture

If you install globalredirect, you will be set for all 301 redirects. The path redirect module is really for when aliases change or you want to manually type in your own redirects (for example, you have migrated to drupal and have old urls to map to new urls).

As for the bulk update of pathauto aliases, you can:

1) go to admin/content/node page
2) check a bunch of pages
3) choose "update path alias"
4) click update

Of course, if you have thousands of pages, this is a pain, but if you only have tens of pages, this is fine.

Good luck,
Kristen
http://kristen.org

I installed Path Redirect

Aleet's picture

I installed Path Redirect and you can set "Default redirect status: " to 301.

Does anyone know how I can tell if it really does?

I ask because it also says setting for "Automatically create redirects when URL aliases are changed." but in my tests it did not.

Testing 301 redirects

Kristen Pol's picture

There are lots of free sites to check your status code like this one:

http://tools.seobook.com/server-header-checker/

For example, if I type in http://kristen.org/node/1

I see:

Requesting http://kristen.org/node/1
SERVER RESPONSE: HTTP/1.1 301 Moved Permanently
Date:    Thu, 09 Jul 2009 19:10:05 GMT
Server:    Apache
Cache-Control:    store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires:    Sun, 19 Nov 1978 05:00:00 GMT
Set-Cookie:    SESS9d41902f12d03526e208e51edeae1530=un6fjfqbhfgvcakh3fkii9vqq0; expires=Sat, 01 Aug 2009 22:43:25 GMT; path=/; domain=.kristen.org
Last-Modified:    Thu, 09 Jul 2009 19:10:06 GMT
Location:    http://kristen.org/drupal-programmer
Content-Type:    text/html; charset=utf-8 
Redirecting to: http://kristen.org/drupal-programmer

http://kristen.org

My solution:



Currently part of the team at https://lastcallmedia.com in a senior Drupal specialist role.