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?

  • 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, 2011 at 2:02
  • Is your website on Apache or IIS or something else? Jul 25, 2011 at 11:10
  • Apache 2.2 version
    – Pacerier
    Jul 26, 2011 at 13:33
  • Possible duplicate: webmasters.stackexchange.com/q/24859/4033
    – Sinan
    Jan 22, 2012 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. Feb 21, 2012 at 17:04

4 Answers 4


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.

  • 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. Feb 22, 2012 at 21:12

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.


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

  • DNS Address Record
    – MattyD
    Jul 27, 2011 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. Feb 22, 2012 at 21:16

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.

  • i couldn't understand that answer at all.. where do i put the <virtualHost> tag?
    – Pacerier
    Jul 26, 2011 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, 2011 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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