views:

102

answers:

2

Hello!

I'm not that good with .htaccess, so I wonder, how can I rewrite default 'node' part of the url to an 'article' for example, so that server will output 'article/1' instead of 'node/1'. I need this to be done on a server side, so with the use of .htaccess only. Any guess?

A: 

Well, the first problem is that you don't understand what mod_rewrite (which is what's doing the work you want, not .htaccess) does. It doesn't change the HTML you're outputting; it changes how the server interprets incoming URL requests.

So if your Drupal install understands node/1 and you want people to see article/1, first you need to modify the HTML output so it embeds links to article/1. Then you rewrite from article/1 to node/1 like so, in a .htaccess or Apache config file:

RewriteEngine on
RewriteRule article/ node/ [NS]
chaos
+3  A: 

The Pathauto module will allow you to set customised paths like this in Drupal. It's a must-have for Drupal (should be in Core, really). Just install and configure via the easy web-interface and you'll be all set.

You can even have different patterns for different node types. As an example, if you had 'page' and 'news' content types, your pages could have URLs like http://example.com/about-us while your news items could have urls like http://example.com/news/2009/05/28/news-post-title.

ceejayoz
A downvote? This is the only answer that'll get Drupal to output links to a custom URL scheme instead of `node/1`.
ceejayoz