Rewrite Logging
URL rewriting is a hard process to debug. However much you tweak, hours of trial and error later you still cannot see the problem with your RewriteRule. Yet it still sits there, stubbornly refusing to work.
The bad news first, there is not a magic solution to this. In fact, if you are just starting off into the world of mod_rewrite, I would recommend you post your problem in our forum and see if we can help you.
If you prefer to go at it alone, here is the good news. You can enable a RewriteLog that, surprisingly enough, will log everything the module is doing. To be perfectly honest, it is not a huge help but if all else has failed, it should be better than nothing.
Enabling RewriteLog
Again, you need root access for this. Open up your Apache httpd.conf file and add in at the very end:
RewriteLogLevel 5
Change /home/path/to/desired/log/file.txt to a valid path to where you wish to have the log file created. The second line specifies the amount of detail the log gives you - 0 logs nothing, 9 will create massive log files. 5 is a good level of detail.
Now save the conf file and restart Apache.
Make a request for the page you are trying to rewrite, then you can check the log file and see what happens. If it helps, problem solved.
Important Note
As soon as you have finished with the log, turn off rewrite logging. You must remove or comment out the two lines you added in and restart Apache again - on a live server, just with a small amount of traffic, your log file can reach gigabytes in size very quickly.
It will also have a performance hit, so be sure to turn it off again.