.htaccess tutorial

htaccess Elite


Rewrite to Index.php

Ask your mod_rewrite and Redirection questions here, and get answers!

Rewrite to Index.php

New postby emptypixels » 18 Nov 2009 23:21

This is my first real attempt at messing with htaccess, so any guidance is much appreciated.

I'm trying to redirect from:
mydomain.com/keyword or www.MyDomain.com/keyword
to:
www.mydomain.com/index.php?id=keyword

In all instances, I'd like to force WWW to be included in the final URL, and I'd like to force the URL to be in all lowercase.
So far, I've figured out how to include WWW when not included, and I've worked out how to add on 'index.php?id=', but I'm not having any success in having this work if they DO remember to add the WWW to the URL.

I have no idea how to force the entire URL to lowercase.

Here's what I have so far. I'm guessing I'm fairly far from the mark on this one?

Code: Select all
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.mydomain.com$
RewriteRule ^(.*)$ http://www.mydomain.com/index.php?id=$1 [R=301]


Thank you for any help.
emptypixels
 
Posts: 1
Joined: 18 Nov 2009 23:10

Return to Redirect or Rewrite Questions