In original vi, and in tools with POSIX BRE or ERE, there's no way to look for strings not at the beginning of the line. However, in all of these, you can use regex groups to match any character before your actual target pattern, and then keep it unchanged in the replacement.
In general, when you want to insert something between two strings, you use groups, like so:
s/\(pattern1\)\(pattern2\)/\1 foo \2/
Correspondingly, to match something not at the beginning of the line, it will be the second pattern, and a
. will be the first. And for patterns not at the end of the line, it will be the first, and a
. the second: