DNS issues

wviperw

Senior member
Aug 5, 2000
824
0
0
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!
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
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.

 

wviperw

Senior member
Aug 5, 2000
824
0
0
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?
 

Thyme

Platinum Member
Nov 30, 2000
2,330
0
0
Rewrite domain2 to example.domain1 and setup the subdomain on domain1.
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
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.

 

wviperw

Senior member
Aug 5, 2000
824
0
0
Yes, I could do that. However, I was really hoping to stay on domain2.com when redirecting.
 

wviperw

Senior member
Aug 5, 2000
824
0
0
Finally got it:

RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/index\.html$ [NC]
RewriteRule ^ http://sub.domain2.com [R,L]
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |