I recently just found the URL rewriter module in drupal. I was wondering if there is a way that I can get it to make a new rewrite when I make a new story. Like automatically rewriting node/23 to /story/title_of_story.html.

Help will be very appretiated, thanks.

Comments

kbahey’s picture

You need two modules to do this:

- path, this is part of the standard Drupal core. Just enable it.

- pathauto, this is a contributed module.

Just enable both, and configure pathauto to your liking

You can make nodes automatically be:
/category/title-words-here, or
/category/yyyy/mm/dd/title-words-here.html ...etc.

Enjoy
--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

Stefan Nagtegaal’s picture

how about:
- story/node-title
- book/node-title
- forum/node-title

So depending on the node-type instead of the taxonomy structure..

kbahey’s picture

pathauto does not seem to do that out of the box.

I can't find it in cvs.drupal.org for some reason, but I checked my 4.5 version, and it seems adding node type is relatively straightforward.

Oh, and it does the taxonomy hierarchy too. Using [catpath] instead of just [cat] does that.
--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

Jaza’s picture

Pathauto doesn't do this to date (afaik), so you have two options if you want aliasing based on node-type:

  1. Use conf_url_rewrite() to rewrite your paths (see the handbook page on URL aliasing for details on how to do this)
  2. Extend pathauto so that it does this

Since this is a relatively simple aliasing operation, I would suggest that using conf_url_rewrite() is the easiest way to do it.

Jeremy Epstein - GreenAsh

Jeremy Epstein - GreenAsh

Stefan Nagtegaal’s picture

The problem is that I don't know how i can use the $node->type inside the conf_url_rewrite() function...
Could you tellme that Jaza?

jdmquin’s picture

I patched pathauto so you can have different paths for each node type. I also added [nid] and [user] as place holders. The patch is at:

http://drupal.org/node/20094

Thanks

JJ