Hi,

I'm looking for a way to print the url of certain content types.
Similar to the way dribbble.com shows a short link to each 'shot'

The first and easiest solution i'm looking for is to have the node id (numerical) : website.com/nid
The ideal one would be to use a shortened version of the domain name (which i already own) and the node id : wb.st/nid

Or to let users choose the url with a token : website.com/token

Any ideas ?

Comments

Codeblind’s picture

A non-SEO friendly technique would be to use mod_rewrite to Redirect from short URL to the long URL, but omitting the R flag so as to prevent the address bar from updating.

Codeblind’s picture

I've been playing around with it, and it looks like you'll have to use mod_proxy and mod_proxy_http too, unless you don't mind the address bar changing.

Another option could be to use PHP (and mod_rewrite) at your shorturl.tld to pull the content using file_get_contents() something like...

// Assumes search friendly url wb.st/123 maps to wb.st/index.php?nid=123
if (array_key_exists('nid', $_GET)) {
    $nid = (int) $_GET['nid'];
    if ($nid > 0) {
      $url = 'http://example.com/node/'.$nid;
      print file_get_contents($url);
   }
}

If the address bar changing and loading a new page is OK, this should work too.

# file: .htaccess
RewriteEngine on
RewriteRule   ^([0-9]*) http://example.com/node/$1 [L]
shadcn’s picture

  1. Install Pathauto (http://drupal.org/project/pathauto)
  2. Go to Configuration -> Search and metadata -> URL Aliases -> Patterns
  3. Use [node:nid] for the node pattern
  4. Then delete (Configuration -> Search and metadata -> URL Aliases -> Delete Aliases) and rebuilt (Configuration -> Search and metadata -> URL Aliases -> Bulk Update) your paths.