I've got mod_rewrite working great using this simple .htaccess: Options +FollowSymLinks RewriteEngine On RewriteRule ^(.+)/(.+)$ http://localhost/testsite/index.php?cat=$1&grp=$2 [L,R] So when I enter http://localhost/testsite/home/prod1 it gets resolved to http://localhost/testsite/index.php?cat=home&grp=prod1. My problem is the ugly URL is displayed in the browser's address field. How do I get the clean URL to display in the browser's address field? Thanks.
Change the URL in the destination to a path and remove the Redirect flag. Options +FollowSymLinks RewriteEngine On RewriteRule ^(.+)/(.+)$ index.php?cat=$1&grp=$2 [L]
Thanks for the help - that worked great but seems to have caused another problem. When I type in http://localhost/testsite/home/prod1 to my browser the page is displayed and the browser address shows the same clean URL. Perfect! But now my links have http://localhost/testsite/home prepended to them. So if I have a link in my HTML of page.php it shows as http://localhost/testsite/home/page.php when I really want http://localhost/testsite/page.php. Likewise if I type http://localhost/testsite/photos/prod2, then http://localhost/testsite/photos is prepended to all my links.
If the script is generating relative URLs, (i.e. simply href="page.php"), your browser takes these to be relative to the current directory. There's no way of knowing you're actually using mod_rewrite to rewrite these requests back up to the main directory - it assumes the links are supposed to be relative to the current (i.e. /home/) folder, even if no such folder physically exists. You can get around this either by editing the script to generate absolute URLs (href="http://localhost/testsite/page.php") or add a base HTML tag to your template: <base href="http://localhost/testsite/"> As you can probably guess, that tells the browser that all links should be relative to the testsite directory, not the current directory.