Website injects random subdomains in URL

I have a live site that is generally running well.
It is built using SilverStripe (cms/framework) and thus uses url rewriting to create the required paths.

    <Files *.ss>
        Order deny,allow
        Deny from all
        Allow from

    ErrorDocument 404 /assets/error-404.html
    ErrorDocument 500 /assets/error-500.html

    <IfModule mod_alias.c>
        RedirectMatch 403 /silverstripe-cache(/|$)

    <IfModule mod_rewrite.c>
        SetEnv HTTP_MOD_REWRITE On
        RewriteEngine On
        RewriteBase /

        RewriteCond %{REQUEST_URI} ^(.*)$
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]

so sometimes my site will load as (where random is anything… but I have seen things like ‘shop’, ‘aaa’, ‘xml’, ‘jkl’ etc…)
and all links in the page will contain the ‘random’ element since they are built using the Base tag.
Is there a way to add a rewrite statement that will force www… (I have 2 other subdomains that I would like to allow as well)??
This has been stumping me for sometime.