[thelist] making friendly urls

Jackson Yee jyee at vt.edu
Sun Aug 18 21:51:01 CDT 2002


----- Original Message -----
From: "Tom Dell'Aringa" <pixelmech at yahoo.com>
To: <thelist at lists.evolt.org>
Sent: Sunday, August 18, 2002 18:45
Subject: RE: [thelist] making friendly urls

> After doing some research on some of the suggested articles and
> searching about myself, I'm not now so sure this is necessary. Doing
> a search on some authors on google comes up with some pages (although
> out of date :( ) that are on the site above. The full URL WITH the
> ?..etc was indexed. It also came up on like the 3rd page, decent
> results since I have not done any real optimization with the site.

Google will index *some* URLs with query strings, but not many, and you won't
have a good place in the rankings either.  Besides, the advantages of being
able to redo the internals of your site at will without having to worry about
bookmarks and links breaking is a wonderful benefit, as you can switch
scripting languages, database structures, file directory structures, and so
forth all without your visitors noticing any changes.

> It seems to me for what you have to go through to get such "friendly"
> urls isn't worth the trouble. Plus, now, I have ONE article page that
> displays EVERY article. I don't want to end up static article pages,
> that defeats the purpose of a templated site driven by a DB.

I don't know how you were planning to do your pages, Tom, but it really
doesn't take very much trouble at all.  For my site, I have the following
lines in a <Directory> section in httpd.conf for Apache,

RewriteEngine On
RewriteBase /

RewriteRule ^articles/([0-9]*)\.html$ articles.php?id=$1 [L]

and that's all that's needed to change any requests from the form

/articles/289263.html

to

/articles.php?id=289263

You don't actually have static article pages on the filesystem.  They only
appear static because of the mechanism which you are using to redirect the
original URL to the correct content.  I actually wrote an article detailing my
experiences with Apache and mod_rewrite if you want a quick read:

http://jacksonyee.dnsalias.com/articles/13.html

You'll quickly recognize the power and ease of rewriting URLs after you start
using it, and it'll soon become second nature.  On my new site which I'm
developing, *every* single page on the site is loaded from one single script
file which takes the URL and loads the appropiate content from a table within
a MySQL database.  It'll obviously take a bit more processing, but as I'm not
concerned about scability with this being a simple site, it'll allow me to map
addresses which are easily human-readable such as

/articles/mod_rewrite/page1.html

into the more cryptic

/index.php?PageType=articles&Title=mod_rewrite&Page=1

for easy maintainability and updates.

I'd suggest that you try rewriting URLs.  If it's not for you, that's fine,
but I think that you'll see that it's actually a really simple way of making
your site more accessible and more friendly to people.

Regards,
Jackson Yee
jyee at vt.edu
http://www.jacksonyee.com/




More information about the thelist mailing list