Drupal 301 Redirect
This weekend while working on one of my drupal sites - yeah I'm new to it and still learning just how to manipulate this content management system.
I needed to find out how to do a 301 redirect, a quick search on google turned up quite a few search results. As I went through them, I really became frustrated most of the advice and examples had me doing a 301 redirect by typing in code into the .htaccess file.
While no stranger to working with this file I could just not get the examples to work as desired. Other methods suggested creating 301 redirects for drupal by creating individual 301 headers.
I really felt there just had to be a much easier way. After hours of frustration and still more searching, I found just what I was looking for even though it was still in the development stage for Drupal 6.
The module is called Path Redirect twenty minutes later I was in business, task completed. Hopefully you'll find this post and it will provide the answer your looking for.





installing a module
i am a serious noob but could you explain or direct me to a very direct explaination of how to install a module?
This Path redirect looks like what I need.
Phil
philmiller278 @ gmail . com
Installing a module is just a
Installing a module is just a matter of uploading the it to the modules folder. Then activating the module found under > Site Building > Modules. You want to make sure that you get the version that is right for your version of Drupal.
I am still learning just how to work within this CMS version with a lot of trial and error along the way. Still I like what I'm finding.
The 301 redirect was needed for another site that I've built and really wanted to change the linking structure to both make it shorter and more eye appealing as well.
The challenge in finding the information is in asking the search engines the right questions. But expect to find generally older information that no longer may apply.
You may want to look at the
You may want to look at the excellent video tutorials at masteringdrupal.com (especially the SEO series) to understand and implement some of the modules in drupal that help SEO.
venkat-rk@drupal.org
A simpler, more brutal approach
Not sure why anyone would think downloading third party code is the best route to creating 301 headers when you can just write them out yourself inside a Drupal page. No configuration, no incompatibility, just works. Like so:
Admin | Create content > Page
<?php// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.yourdrupalsite.com/node/123");
exit();
?>
You just need to make sure you select PHP code in the Input Format group box when creating your content, and that's it. An additional benefit of this method is that the code required is both minimal and unambiguous: many Drupal modules are, I have found, very poorly written and can impact system security. This method does not.
To edit the page once you've created it (because, of course, each time you view it you will be redirected) make sure you drill down through the Administer areas:
Admin | Administer > Content management > Categories > Content
i.e. http://www.yourdrupalsite.com/admin/content/node
Just click Edit from the Operations column and you're away.
I'm using Drupal 4.x so YMMV :)
Domain Redirect
Why not use Domain redirect from Cpanel? That's much simpler.
Cpanel?
That would be another option if you where using Cpanel. With a module it does not matter what hosting platform your using.
PHP code does not work when
PHP code does not work when your node or page has been cached by Drupal. When the page has been cached it is not able to run the php code anymore.
Well, what actually gets
Well, what actually gets cached in this case is an HTTP response with the redirect, so I don't see that as a problem here..
I was wondering how to handle
I was wondering how to handle all of the 301s because I am migrating a very old site to Drupal, and there are going to be a vast number of URL changes.
It looks like the Path Redirect module is still in beta, so I'm still not sure if I'm going to use it just yet.
BTW - This is an awesome source of Drupal info, I'm subscribing to your feed.
Post new comment