1

I have a secondary domain name which I need its subdomains to point to my main domain. For example,If my main domain is example.com, then I have used example.org to point to the former. What I desire to achieve is for all subdomains of the main one to be also pointed at by the secondary domain. I mean, for instance, if I have

example.com/about
example.com/contact
.
.
.

I want them also be pointed at with

example.org/about
example.org/contact
.
.
.

Please let me know how I can do that through mod_rewrite rules as the examples I have found through googling, only focus on redirecting from a secondary domain to the main one, without mentioning how to redirect the subdomains as well.

PS: Currently, example.org is correctly replaced with example.com. But for subdomain it is not so. I mean, for instance, example.org/contact is not replaced by example.com/contact.

Update: My htaccess file includes the following

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
developer
  • 535
  • 2
  • 8
  • 15
  • I'm not quite clear on what you want to happen. Do you want e.g. **http://example.org/contact** to have the exact same content as **http://example.com/contact**, or do you want a redirect so that the text in the browser's address bar also changes? What does your current config look like? – Jenny D Mar 24 '15 at 11:03
  • 1
    And, kudos for using the correct example.org/example.com domains! – Jenny D Mar 24 '15 at 11:03
  • Side note: that's not what a subdomain is. http://en.wikipedia.org/wiki/Subdomain I'm pretty sure you can use a CNAME DNS record for this, or an http redirect on the host. – Todd Wilcox Mar 24 '15 at 11:15
  • @Jenny D Thanks for responding and sorry if my explanation was not clear. I want the second alternative to happen. I mean, I want the browser's address change. The content is the same. It is only a second domain name pointing to the original one. And as I am using DirectAdmin panel, I only had to add the second domain in the 'Domain Pointers" section of the panel, so the secondary domain is now easily replaced with the main domain name. Please let me know if I have to provide more information. – developer Mar 24 '15 at 11:24
  • @developer I think that you'll find the answer in the canonical mod_rewrite QA, at http://serverfault.com/questions/214512/everything-you-ever-wanted-to-know-about-mod-rewrite-rules-but-were-afraid-to-ask - if that doesn't help you out, please include your current configuration in your question, that will make it easier to help you. – Jenny D Mar 24 '15 at 11:34
  • @Jenny D I think I have followed the same rules for the mod_rewrite rules I have added to my htaccess file. I will add the lines above. – developer Mar 24 '15 at 11:53
  • Well, that looks like it should do what you say you want it to do. But, the thing about the subdomains isn't clear from your question. Do you mean that you want e.g. `foo.example.org/contact` to be replaced by `foo.example.com/contact`, and not by `example.com/contact`? – Jenny D Mar 24 '15 at 11:58
  • I think there is misunderstanding. Is it ok if I refer to /contact/ in example.org/contact as a subdomain or it has another name? I do not need subdomains in the format of foo.example.com but similar to example.org/foo. – developer Mar 24 '15 at 12:16
  • Perhaps I should refer to that as subdirectory. – developer Mar 24 '15 at 12:30

1 Answers1

1

In DA go to the following path:

User level --> Domain pointer

Uncheck "Create as an Alias" before adding your second domain. The domain type, then, will be "pointer" which solves your problem.

ajax20
  • 110
  • 1
  • 1
  • 6