I've some difficulties for mod-rewrite ruleset on my small linux + Apache 2.x webserver.

Product PID has CG000XXXX format.

I wish to call PID with shorten URL. Basically access with www.DOM.com/?1234 call www.DOM.com//product/detail.jsp?pid=BG0001234

I applied following on my small httpd.conf

RewriteEngine On
RewriteRule ^/?([0-9]+)$ /product/detail.jsp?pid=BG000$1 [NC,L]

It work.. but call wrong PID.

Help... Thanks ahead of time.

The guidelines are ok. Enable debugging on mod_rewrite and appear what's happening whenever you access the url. I presume is a concern between Apache as well as your java application server.

RewriteLogLevel 3 
RewriteLog "/TMP/rewrite.log"