Q:
Is there a way around using regular expressions, maybe by skipping the subdomain in the $1 backreference?
The restriction is that it should apply only to this specific subdomain from the old domain. Other subdomains may not be affected…
I think that your host’s setup is probably of the type which does NOT allow the subdomain to remain in the URL (some cPanels do that, some don’t).
To get around that, you’ll have to capture the subdomain in a RewriteCond statement and include it in the regex of the associated RewriteRule, i.e., something like:
We just decided to move the files for this subdomain to a new domain and decided not to use a subdomain as a url anymore.
Is seems that your solution is directed towards all sudomains in the old domain. Since we are running a CMS with its own .htaccess directives, this does not apply.
I have tried your code code in original and adjusted form even with the subdomain alone like in:
But I get 403 forbidden and 500 internal server errors (for the error pages) due to - I assume - <Filesmatch> and ErrorDocument directives in the .htaccess of the CMS that is running on the same server.
It’s a litte bit complicated situation since the subdomain I want to redirect resides on the same server as the CMS but is not a part of the CMS. We used the old subdomain for CNAME forwarding to a different site.
It seems that only non-specific redirects to the new domain work, like:
I don’t quite understand how your server would provide the domain’s address for the subdomain access (unless your CMS’s mod_rewrite is interfering) but the above code should make that irrelevant.