By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 926 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

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

P: 13
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
Nov 18 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.