its funny, I wrote exactly the same module two days ago.

I think you should use drupal_get_path_alias, because if you use drupal_lookup_path directly it is not possible to define a custom_url_rewrite-function

here comes a patch which replaces it
beside this the check for function_exists('drupal_lookup_path') is not necessary because it exists in every drupal 4.7 and drupal 5.

---

I want to point you over to a patch for drupal core I wrote which sets the alias of your frontpages' path to ''.
example:

print 'Alias of frontpage='. drupal_lookup_path('alias', variable_get('site_frontpage','node'));
// Output:
//  currently:
//  Alias of frontpage=node
//  after this patch:
//  Alias of frontpage=

url() does not recognize if $path == frontpage
I think this may be interesting in this context

CommentFileSizeAuthor
globalredirect.patch.txt943 bytesTobias Maier

Comments

nicholasthompson’s picture

Interesting... You address few points here.

  1. Use of drupal_get_path_alias over drupal_lookup_path due to to the use of custom_url_rewrite(). This sounds like a sensible replacement - however I cant find any documentation on that functions. Whats its use? Apart from that - that sounds a sensible suggestion.
  2. In your patch you change the !empty() test to a !==. What does this achieve over !empty? The other changes in your patch are a good idea. I'll implement those in the next release.
  3. Your other issue with frontpages - I have noticed this before but not considered it a massive issue, however if there is a simple fix then lets take it! You suggest making an alias from whatever your frontpage url is (eg http://www.example.com/welcome) to just the base path (eg http://www.example.com). I cant see any reason why this wont work. In fact, with the alias in place ("welcome" as the src and "" as dst) surely global redirect solves this?
Tobias Maier’s picture

  1. about Mass URL aliasing with custom_url_rewrite()
  2. empty() is slow in general. drupal_lookup_path() returns FALSE if it does not find a proper alias. so why not check for this? (beside this empty(0) returns true, too which is not right in our usecase)

    later on if we swich to drupal_get_path_alias() we have to compare
    if ($_REQUEST['q']==drupal_get_path_alias($_REQUEST['q'])) {}

  3. we cant define an empty alias in our UI - beside this we defined the front page at admin/settings so drupal should do the right converison of this path by default
nicholasthompson’s picture

I just learned something :-)

beside this the check for function_exists('drupal_lookup_path') is not necessary because it exists in every drupal 4.7 and drupal 5.

That bit is very necessary as without it, pages dont load! I think the function may get called twice - the first time seems to be before anything has loaded, such as the ability to lookup paths.

Apart from that, the Sportbusiness.com site seems to be running fine with the other changes such as the !== comparision.

I'll have a read of the mass URL aliasing document tomorrow - I like the sound of that. It might solve the issue with us having 25,000 aliases for news items! Alternatively, it might just allow the possibility for multiple urls to server the same page.

nicholasthompson’s picture

Status: Needs review » Fixed

fixed in version 1.3...

It now…

Cheers for pointing those out.

Anonymous’s picture

Status: Fixed » Closed (fixed)