You can dynamically set the url in config.php based on server variables (it's not a static file, it's a php file), but this usually doesn't make sense to do that.
It might be more interesting to go back one step before and ask why you need two domains ? This will create duplicated content (and therefore bad ranking) from an SEO perspective. If you want multiple domains to resolve to your forum, how about just setting redirects ?