How do I change the URL on my Drupal install to be like twitter:

http://www.domain.com/admin

This would be the same as /user/1 in drupal.

function liketwitter_menu() {
  $items['%'] = array(
    'page callback' => 'liketwitter_url',
    'page arguments' => array(0),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK
  );
  return $items;
}

function liketwitter_url($username) {
  // Here do a node load. It would be ideal if a drupal_goto is not required. Maybe forward/reverse proxy?
  $nid = node_load(....);
  drupal_goto(drupal_get_path_alias("user/$nid"), NULL, NULL, 301);
}

Maybe a combo of apache reverse proxy and drupal menu?

Anyone done this?

Comments

davidwheelerphd’s picture

billnbell’s picture

This is good, but not exactly what I want.... In Java I would create a Tomcat filter to do this... Not sure the facility in PHP....

Bill

himerus’s picture

I'm confused... wouldn't pathauto handle this?? drupal.org/project/pathauto

You can set your user profile alias to just be [user-raw]. My current install (I think default) uses users/[user-raw]

The only issue with this is you have to ensure that none of your normal content ever uses a root path.... but using something like twitter's style you could use for your default node type alias to be:

[author-name-raw]/status/datestamp

I don't see an actual timestamp token in pathauto, but you could use a combination of the available date tokens and there you go.

Unless I misunderstand the need, this would handle it, and pathauto is a very popular module.

billnbell’s picture

himerus. I am already using pathauto for several content types. I want the URL to be:

http://www.domain/billbell

Not

http://www.domain/user/billbell

There appears no way to create a menu default or fallback. "user/%user" is possible, but "%user" is not for the menu as far as I can see.

Thanks.