lucy24 - 1:07 am on Apr 15, 2013 (gmt 0)
Replacing www. with www/ is trivial; mod_rewrite unlike some mods doesn't give any special treatment to the / character. But I don't understand how it fits in with the quoted rule. I don't see any "www" in there, and no clue where it might occur.
Matter of fact, you won't need a "www" at all. You can call the subdirectory anything you like. It can be /www/ but certainly doesn't have to be.
Now that we've established that I'm not going to answer your question ;) --at least not right now-- let me toss out some other stuff.
#1 Wouldn't it be more efficient if the body of the rule specified the extensions the rule does want, instead of going to a condition to exclude the ones it doesn't want? The combination of /images and /sounds in the pattern, with !\.(gif|jpg|js|mp3|png)$ in the rule, definitely looks funny. Just what have you got in those directories, if not sounds and images?
#2 Why does the pattern start with ^[^/]*/ ? Are you getting a lot of malformed internal requests that have an extra / slash at the beginning? In htaccess, a normal request will start with a non-slash character, representing the first letter after "example.com/" (or some deeper directory if the htaccess file isn't in the root). As written, the rule will find either requests for a subdirectory-- throwing away the outermost directory, whatever it is-- or malformed requests for a top-level directory with doubled leading slash.
#3 A literal period in mid-URL isn't absolutely forbidden-- apache dot org themselves have buckets of them-- but it's really better if you can get rid of them. Then the only occurrence of a dot . will be right before the extension. This is often useful when you're constructing patterns.
... (images|search|scripts|sounds)(.+) $1$2 [QSA]
Can I assume the first group is always followed by a directory slash and then more stuff? If so it could also be expressed as
resulting in a single $1 capture.
#5 The [QSA] isn't needed, because that's the default behavior unless you've explicitly added a new query. It also, of course, isn't needed if there was no query in the first place. Your rule doesn't give any hint about what the file extension is, only what it isn't, so I can't guess. What the rule does need-- and I'm surprised there haven't been unintended consequences-- is an [L] flag.
Oh and Psst! Although it has to be "example" in posts, it doesn't have to be dot com. You can say .org, .net, .uk, .xyz as much as you like if you need to distinguish among different domain names.