I'm having problem with my .htaccess redirection

Hi,
I’m using PHP 5.0 I want to do internal redirection.
ex:
if a url in this format
somthing/hiddendir/sample.html?id=1
then it should redirect to
somthing/maindir/test.php?file=sample&id=5
My Rewrite rule as follow

RewriteCond %{REQUEST_URI} ^/hiddendir/(.)\.html?id=(.)
RewriteRule ^hiddendir/(.)\.html?id=(.) ./maindir/test.php?file=$1&id=$2 [L]

But this is not working
How can I do it help me

Welcome, Vin, to SitePoint’s Apache forum!

Whew! Apache 2.x? Is hiddendir a pseudonym for maindir? I don’t understand your structure.

From what I gather, you want to redirect from URI of som(e)thing/hiddendir/sample.html?id=1 to som(e)thing/maindir/test.php?file=sample&id=5. Unless you want to hardcode those {QUERY_STRING} values, it’s not possible as there is no way for mod_rewrite to map from A to B!

IMHO, you need to read the mod_rewrite tutorial linked in my signature. There you will find that you need to address the query string with a RewriteCond %{QUERY_STRING} id=([0-9]+)$ OR id=([^&]+)

If your som(e)thing is your domain, you can use the RewriteRule to test the URI (NOT the query string) and redirect on the basis of the RewriteCond AND the RewriteRule.

Go have a read and come back with questions.

Regards,

DK