#1 If the rule is only meant to apply to requests for /hotels-details then put that in the body of the rule. Otherwise your server has to evalute conditions on every single request ever.
#2 Whenever a rule creates an external redirect (R flag) include the full protocol-plus-domain in the target.
So the rule quoted above should say
RewriteCond %{THE_REQUEST} ^GET\ /hotels-details\?hotelcode=(\S+)&hotel_key=(\S+)&hnm=(\S+)&hct=(\S+) [NC]
RewriteRule ^hotels-details$ http://example.com/hotel/%3-in-%4-%1-%2? [R=301,L,B]
return URL as per my need but showing error 404(page not found)
Can you rephrase this, please? It isn't clear whether the two elements (the final URL and the 404 error) are what
does happen, or what
should happen. I assume you are not a native speaker of English. So it may take a few attempts for all of us to understand each other.
If you have made a rule creating a redirect to a new pretty URL, then there
must also be a rule creating an internal rewrite to wherever the content really lives. You haven't said anything about this second rule.
If the old messy URL is where the page content still really lives, then you do need a condition involving THE_REQUEST. If the page content lives at some entirely different location, you can drop THE_REQUEST and instead make a condition looking only at QUERY_STRING.
<tangent>
Why is the [B ] flag needed? Just curious. I first thought it might be because some URL elements involve non-Roman scripts, but the Apache docs say [B ] applies only to non-alphanumeric characters. (They may be wrong about this, though. Maybe they mean non-ASCII.)
</tangent>
(I had to write it [B ] with spurious space, because the Forums software made a fuss.)