• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

DNS issues

wviperw

Senior member
So I've got 2 domains pointing to the same hosting box. Let's say they are domain1.com and domain2.com for illustrative purposes. Right now both domains go to the root of the hosting folder, meaning they take you to the same place (basically domain2 is an alias for domain1). What I want is for domain2.com to actually take you to a separate part of the website, namely a specific folder/sub-domain, e.g. - subdomain.domain2.com

Now I know there is a hack-ish way to do this by using server side code and doing a redirect, but I'm trying to handle it at the DNS level. I tried creating a CNAME entry for domain2 that maps 'www' to 'subdomain.domain2.com' but then nothing works and loading domain2.com gives me the message 'This website is temporarily unavailable, please try again later.'

Anybody know the right way to address this? Thanks!
 
Originally posted by: wviperw
Now I know there is a hack-ish way to do this by using server side code and doing a redirect, but I'm trying to handle it at the DNS level.
You've got it backwards. DNS maps names to IP's, not names to parts of a website. What you're attempting is hackish - you're trying to make DNS into something it's not. Server-side redirects are the appropriate way to do this. You want to configure the web server to provide a permanent redirect from www.domain2.com to subdomain.domain2.com.

 
Oh, so I was going at it in completely the wrong way. 🙂

So now that I know the correct angle to approach it from, I'm trying to edit the .htaccess file with some mod_rewrite commands:

RewriteEngine on
rewritecond %{http_host} ^www.domain2.com [nc]
rewriterule ^(.*)$ http://example.domain2.com/$1 [r=301,nc]

However, as you can imagine, it ends up in an infinite loop of endlessly redirecting to itself (since the host is always domain2.com). Surely there is a better way?
 
Originally posted by: wviperw
However, as you can imagine, it ends up in an infinite loop of endlessly redirecting to itself (since the host is always domain2.com). Surely there is a better way?
Yeah, use the webserver's built-in redirect function for the appropriate virtual host. For Apache, it looks like

<VirtualHost *>
DocumentRoot /some/empty/directory
ServerName www.domain2.com
Redirect permanent / http://subdomain.domain2.com
</VirtualHost>


If you don't have direct access to the webserver config files, see if there's some kind of control panel option or if the hosting company can set it up for you.

 
Back
Top