1

Is it possible to create a Mod Rewrite rule to point a subdomain to a TLD? Example; cars.test.com -> Mycarsite.com

Am using the shared cookie, tables (for the users), and Domain access in D7. Now all I need to do is craft a rewrite rule that can point all the requests going to subdomain.tld.com to goto mytld.com.

CLARIFICATION/EDIT: This is specifically a drupal question. I shared the users with test.com & cars.test.com so that I can do a single sign on. So I did the typical adjustments to settings.php and crafted the single db with prefixes per site. The only "out of the box solution" that works with D7 for an SSO solution is sharing the DB and and sharing cookies. I got that part working. Now this is the part that am experimenting with but am not sure its possible. I want all requests that goto cars.test.com appear as if they are coming from mytld.com. I already have mytld.com parked on the host. But when I goto cars.test.com using the mod rerewrite rules from @acouch below, it redirects me test.com. Is this possible?

5
  • What do you mean by "I want all requests that goto cars.test.com appear as if they are coming from mytld.com." ?
    – acouch
    Mar 14, 2012 at 21:30
  • Ok lets say a request goes to [sub.tld].com/node/* . When the user goes to [anotherTLD].com, the site is located at [sub.tld].com. So what I need is when a page is generated [sub.tld].com/node/* it will appear in the url as [anotherTLD].com/node/*.. I hope this makes sense. I've confused quite a few people in the past two days with this question. Mar 16, 2012 at 4:29
  • When you say "appear" is that different than "redirect"?
    – acouch
    Mar 16, 2012 at 12:48
  • Well [anotherTLD].com/node/* doesnt exist. But [sub.tld].com/node/* does. I want the end user to type [anotherTLD].com/node/* instead of [sub.tld].com/node/* to reach content. Mar 20, 2012 at 21:46
  • It is not TLD what you are talking about, it's the host name. TLD is the last part of the URL, like com, org, net etc...
    – Elin Y.
    Feb 20, 2016 at 18:18

1 Answer 1

0

This should work:

RewriteCond %{HTTP_HOST} ^subdomain\.tld.com [NC]
RewriteRule ^(.*)$ http://mytld.com/$1 [L,R=301]

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.