Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to park my domain www.b.com to www.a.com

So far is working, but if the user visits b.com, I want the browser url to display a.com

Is there a way around it?

share|improve this question
    
This seems like more of a server question than a programming question. In fact it's basically bog-standard DNS. Take a look at this server fault question. You just use a 301. –  Aaronaught Jul 25 '11 at 2:02
    
Is your website on Apache or IIS or something else? –  paulmorriss Jul 25 '11 at 11:10
    
Apache 2.2 version –  Pacerier Jul 26 '11 at 13:33
    
Possible duplicate: webmasters.stackexchange.com/q/24859/4033 –  Sinan Jan 22 '12 at 15:12
    
@Sinan I think it's actually the opposite of that question - Pacerier wants to redirect the user from b.com to a.com, where as Sunny88 wants duplicate content on the two domains. –  Zhaph - Ben Duguid Feb 21 '12 at 17:04
add comment

migrated from programmers.stackexchange.com Jul 25 '11 at 2:34

This question came from our site for professional programmers interested in conceptual questions about software development.

4 Answers

You could just use mod_rewrite in your .htaccess file.

The Apache docs have a great example: http://httpd.apache.org/docs/2.3/rewrite/remapping.html#canonicalhost

Drop this in your .htaccess file and all requests will be re-directed to www.a.com:

RewriteCond %{HTTP_HOST} !^www.a.com [NC]
RewriteRule ^/?(.*) http://www.a.com/$1 [L,R,NE] 

Also, don't forget RewriteEngine On if needed.

share|improve this answer
add comment

You can simply forward b.com to a.com in your registrar account GoDaddy for example or where ever you registered the domain. This is better than doing it with any server side script. Another option is to create a CNAME record.

share|improve this answer
    
The problem with the CNAME approach is that it'll basically mirror the site at b.com instead of redirecting it. This could have negative SEO impact unless he sets a canonical URL. If he has access to redirect facilities, he should do that instead. –  Lèse majesté Feb 22 '12 at 21:12
add comment

It's a bit unclear where you want the web content to come from. If the user visits b.com, you can set two things in action:

  1. Effect a redirect to a.com, where the content is coming from the server at the other end of a.com and the URL is to match.
  2. Mirror the content of the server at a.com under b.com, with that as the URL being accessed.

If you're serving data from a server at the other end of b.com, you should leave the URL as such. Cloaking it to read a.com is possible with some older browsers, but is a Bad Internet Practice™ for multitudes of security reasons.

It sounds like you'll be most successful with a domain redirect as referenced in @Aeronaught's comment.

share|improve this answer
    
i couldn't understand that answer at all.. where do i put the <virtualHost> tag? –  Pacerier Jul 26 '11 at 21:41
    
@Pacerier That would be in the destination server's own configuration; assuming it's running Apache, that snippet would go in httpd.conf on the server. You need to provide more information on your hosting environment if that doesn't make sense. –  NReilingh Jul 26 '11 at 22:44
add comment

Possible a domain redirect using Domain B's name servers and A Records.

Or using Domain A's control panel to set up a redirect there

share|improve this answer
    
DNS Address Record –  MattyD Jul 27 '11 at 0:14
    
There's no way to do a redirect via DNS. Redirecting is done via HTTP (or JS or http-equiv meta tags). Also, there's no way to get b.com to redirect to a.com by only using a.com configurations. That would allow anyone to steal anyone else's domain. –  Lèse majesté Feb 22 '12 at 21:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.