Hard-coded works:
- Code: Select all
RewriteCond %{HTTP_HOST} !^([^.]+\.)domain.tld$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
But how do we get this to work without hard-coding the domain? I tried to use HTTP_HOST but that often returns the www which is not what we want. Also tried a script I found online that worked for domains with like .com and .net but not for .org.uk or co.uk etc.
Any help would be appreciated.