30-minute modules: Alias
So often there are very simple tasks that never make it into a proper module. Today the need arose for one of these tasks and I decided to take the small amount of time to do it right.
The premise was simple. Have a path on our domain redirect to an external URL. Simple right. There are so many ways to do this, and generally I would drop a line in the .htaccess file. The biggest barrier here is that this requires a trusted developer to edit the .htaccess file. This resulted in the current way things were being done, which is putting a drupal_goto in a node with the PHP filter. All was fine... until cron. When cron tried to run, it would eval this code and redirect to the specified URL.
So I wrote Alias module, while on a conference call. It took all of about 30 minutes to write it. About 20 minutes of that was spent on creating the admin interface to create, edit, delete and list the aliases. In fact, it took longer to figure out a decent name for this module than it did to write it (originally I had named it 'redirect').
Here it is. Hope you enjoy.

2 Responses
Why not just use the existing Path Redirect module? http://drupal.org/project/path_redirect
A young boy and his dad went out fishing one fine morning. After a few quiet hours out in the boat, the boy became curious about the world around him. He looked up at his dad and asked "How do fish breath under water?"His dad thought about it for a moment, then replied, "I really don't know, son."The boy sat quietly from another moment, then turned back to his dad and asked, "How does our boat float on the water?"Nnce again his dad replied, "Don’t know, son."Pondering his thoughts again, a short while later, the boy asks "Why is the sky blue?"Again, his dad replied. "Don’t know, son."Tiffany 1837 The inquisitive boy, worried he was annoying his father, asks this time "Dad, do you mind that I'm asking you all of these questions?""Of course not son." replied his dad, "How else are you ever going to learn anything?"
Post new comment