The Power of Friendly URLs

Eat at URLS

You hear a lot of talk in development circles about the power of Apache, but it's not often that developers of small sites get to leverage this power.

Those days are over thanks to the combination of Drupal and the contributed module Pathauto.

One excellent feature in Apache that you often hear about but rarely get a chance to use is mod_rewrite. Part of the reason for the rare use of this feature is the fact that it is hard to set up, and even harder to set up correctly.

The Drupal installer comes pre-configured to check for mod_rewrite, and will let you turn on what is referred to as 'clean urls' within Drupal. Clean urls are powered by the path module that is present within Drupal core. The path module gives you the ability to manually assign an alias to any piece of content on your site.

Manual aliases are nice and all, but lets face it we're all too lazy to type in all those aliases. Luckily for us there's Pathauto. Pathauto allows you to setup predefined rules that apply automatically to new pieces of content. These automatic rules are nice for a blog where you can have all your blog posts point to /blog/post-name but this is really just scratching the surface of what you can do with Pathauto.

Lets continue with the blog example to show what we can really do with Pathauto. Imagine the scenario that there are two different authors of blog posts, Pathauto uses the Token module to provide a bunch of useful information to build automatic aliases from. So now instead of just /blog/post-name we can have /blog/john/post-name /blog/sally/post-name all happen automatically.

This can become even more useful on a very large site with different types of content. You can have /audio/post-name /event/year/month/date/post-name really the main limitation is your imagination and patience.

So now that we've gotten this far the only question remaining is why would I want to do all this? There are really two main benefits. The first is search engine optimization. Pathauto gives you the ability to load the paths to your content with all sorts of keywords and this is one of the first places Google will look to categorize your piece of content. The second benefit is more for power users. If you regularly visit a site with a well thought out URL scheme you can begin to use the URLS to navigate the site instead of the on-the-page navigation. From the above blog example I might try to type in http://www.examle.com/blog/john and if the website manager was kind enough to set up a View for that path we'll see a pretty listing of all of John's posts.

Did I miss anything? Any other good modules that help out with this area? Let me know in the comments.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options