Regex to rewrite URL to another URL based on HTTP_HOST?

I am trying to find a way to test some code, but I need to rewrite a specific URL only from a specific HTTP_HOST

The call goes out to

http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena

The ID in the middle is always random due to the cookie.

I want for that specific HTTP_HOST when it fetches the URL "http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena" , I want it to get

http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena.v2

Instead.

Is there a way I can do this with mod_rewrite, or regex?

Thanks

sed 's|http://SUB.DOMAIN.COM/showAssignment.*jsmodule/Nevow.Athena|&.v2|'
$ echo 'http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena' | sed 's|http://SUB.DOMAIN.COM/showAssignment.*jsmodule/Nevow.Athena|&.v2|'
http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena.v2

While that will change all the code to look for that URL.

The point of making this rewrite rule is to just affect certain URLs, not everyone. So instead of changing a piece of code that can affect thousands of clients, we just want to affect one client to call the new javascript code, instead of everyone, so thinking of solving this using mod_rewrite.

Thanks

So you have to care about the cookie : this means you have to dynamically get the current cookie of the personne whose requests are going to be rewrite to the new *.v2 URL
so if you have the cookie of that personne in a variable $COOKIE, then :

 sed 's|http://SUB.DOMAIN.COM/showAssignment/'"$COOKIE"'/jsmodule/Nevow.Athena|&.v2|'

Normally, we don't use SED for rewriting URLs via HTTP_HOST. We use Apache2 mod_rewrite, that is why the original poster requested a regex to a rewrite URL to another URL based on HTTP_HOST. isn't that right?

Will this work? Are you looking for a redirect? If not, I think it is better to rewrite to the substitution for Nevow.Athena.v2 rather than Nevow.Athena.v2.

Put this in the .htaccess file in your document root