Connecting Tech Pros Worldwide Help | Site Map

mod_rewrite - Help, I'm a newbie...

Newbie
 
Join Date: Nov 2006
Location: California, USA
Posts: 13
#1: Nov 18 '06
I've got URLs that look like:
Expand|Select|Wrap|Line Numbers
  1. www.mysite.com/template.php?id=pagetitle
  2. www.mysite.com/template.php?id=folder/pagetitle

I want the URLs to look like:
Expand|Select|Wrap|Line Numbers
  1. www.mysite.com/pagetitle
  2. www.mysite.com/folder/pagetitle

How do I write this RewriteRule into my .htaccess file? Or, is there a better way.

I originally wrote a separate rule for every single URL, but, as you could imagine, the performance of the site took a huge hit. (see example below).

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine On
  2. RewriteRule ^$ http://www.mysite.com/template.php?id=home
  3. RewriteRule ^(about/history/|about/history)$ template.php?id=about/history
  4. RewriteRule ^(services/|services)$ template.php?id=services
  5. RewriteRule ^(contact/|contact)$ template.php?p=contact
  6.  
  7. etc., etc., etc.
  8.  
And I thought, "There must be a way to write one or two rules that would cover all these URLs." Any help would be great.

Also, I'm a newbie to code -- design's my gig -- so directing me to the Apache docs will not help me much, unfortunately (as it's Greek to me).

Perhaps an example, or citing an article with examples would help me.

Thank you very much.
Brad
Reply