Move rewrite_old_url() from common.inc to update.php and use it to update the content in the database (instead of rewriting the URLs on the fly). By now, rewrite_old_url() is well tested so it should work fine.

The only alternative is not to rewrite the content and to rely on mod_rewrite to fix it up on the fly which might be a good idea (1) because it will also fix external referrers, (2) because we can't screw up any data and (3) last but not least, given a good set of mod_rewrite rules, people will be able to switch between different (clean) URL schemes.

Then again, for performance's sake, you might want to update the content in the database. Also, not everyone might have mod_rewrite support.

Comments

teledyn’s picture

Title: Remove rewrite_old_url() from filters » Re: [drupal-devel] task #1542 : Remove rewrite_old_url() from filters

It's not only my database, but all the people who've blogged my
content based on the old URLs ... I'm pretty much stuck with not only
old Drupal URLs, but also old Geeklog URLs /and/ I /still/ get calls
for old SIPS urls from 6 years ago! I'm hoping that webhost storage
continues to outpace my consumption so I never have to think about
dropping content.

If you want to keep old connections, you have to maintain them. Were
the web centrally controlled and enforced (a) this wouldn't be a
problem because they'd all be sensitive to Content-Moved status codes
and (b) this wouldn't be a problem because if it was under draconian
control the world wide web wouldn't exist ;)

It's just a fact of life being onling: small pieces, loosely fitting,
or as Stitch said "broken but still quite good" (I highly recommend
Lilo and Stitch; take a 5 year old with you)

dries’s picture

Title: Re: [drupal-devel] task #1542 : Remove rewrite_old_url() from filters » Re: [drupal-devel] task #1542 : Remove rewrite_old_url() from fi

Some observations:

  • mod_rewrite is probably the preferred solution as it fixes external referrers.
  • We can add an entry to update.php to rewrite the posts in the database, though it does not fix external referrers. Care must be taken as rewrite_old_urls() uses the active "clean URL" configuration. By default, clean URLs are disabled so people might want to configure that first or they will end up with "?q=foo/bar"-style URLs.

How about we add an option to enable or disable an output filter based on rewrite_old_url()? The filter should be disabled by default so it does not affect people with a fresh install. People upgrading their pre-"Drupal 4.2.0" sites can enable the filter if they don't have access to mod_rewrite.

killes@www.drop.org’s picture

Title: Re: [drupal-devel] task #1542 : Remove rewrite_old_url() from fi » Re: task #1542 : Re: [drupal-devel] task #1542 : Remove rewrite_old_url() from fi

On 23 May 2003, Dries wrote:

> mod_rewrite is probably the preferred solution as it fixes external
> referrers.

ack

> We can add an entry to update.php to rewrite the posts in the
> database, though it does not fix external referrers. Care must be
> taken as rewrite_old_urls() uses the active "clean URL" configuration.
> By default, clean URLs are disabled so people might want to configure
> that first or they will end up with "?q=foo/bar"-style URLs.

So we better dont mess with it in the first place. Loading and saving
every piece of content is an idea I do not really like.

> How about we add an option to enable or disable an output filter based
> on rewrite_old_url()? The filter should be disabled by default so it
> does not affect people with a fresh install. People upgrading their
> pre-"Drupal 4.2.0" sites can enable the filter if they don't have
> access to mod_rewrite.

I really like this.

Cheers,
Gerhard

dries’s picture

Title: Re: task #1542 : Re: [drupal-devel] task #1542 : Remove rewrite_old_url() from fi » Re: task #1542 : Re: [drupal-devel] task #1542 : Remove rewrite_

I added such filter option and committed this to CVS. Though for this option to work properly, we need "on output" filters. I'll look into Gerhard's filter patch this weekend; this has a dependency on bug #1643 as well.

dries’s picture

Marking this as "fixed" as thanks to the "on output" filters the URL rewriting now works as expected.

al’s picture

Title: Re: task #1542 : Re: [drupal-devel] task #1542 : Remove rewrite_ » Remove rewrite_old_url() from filters
Anonymous’s picture