Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,300
    Thanks
    4
    Thanked 203 Times in 200 Posts

    Redirecting sub-domains and specific directories

    I have a shared hosting account with multiple domains under a single "master" domain. For the purposes of this discussion we'll call the "master" domain xyz.com since the real domain name is rather long.

    The additional domains hosted on the account are added as sub-domains of the master domain so a sub-domain named abc.com is added and shows up as abc.xyz.com. The main domains files are in the public_html directory and additional domains fall below that with any name desired. For our abc.com domain its files are found in the public_html/ABC directory.

    Now the problem I'm having. I want to redirect requests for abc.xyz.com to abc.com ... I also want to redirect requests for xyz.com/ABC to abc.com so the additional domain files never get served as if they were part of the xyz.com domain.

    Using some examples provided by the hosting provider and other resources I've tried the following but it is not doing what is expected.

    Code:
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^www\.xyz\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^xyz\.com$
    RewriteCond %{REQUEST_URI} ^/ABC/(.*)$
    RewriteRule ^(.*)$ http://abc.com/ [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^abc\.xyz\.com$      [OR]
    RewriteCond %{HTTP_HOST} ^www\.abc\.xyz\.com$
    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^(.*)$ http://abc.com/ [R=301,L]
    What I expected to happen with those rules is:

    A: xyz.com/ABC would end up going to abc.com
    B: abc.xyz.com would end up going to abc.com

    Needless to say neither of those things are happening and I'm not sure why. It's probably something obvious but darned if I can see it. Any assistance or pointers would be greatly appreciated.
    Dave .... HostMonster for all of your hosting needs

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,300
    Thanks
    4
    Thanked 203 Times in 200 Posts
    Quote Originally Posted by djm0219 View Post
    Code:
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^abc.xyz.com$         [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.abc.xyz.com$ [NC]
    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^(.*)$ http://abc.com/ [R=301,L]
    What I expected to happen with those rules is:

    B: abc.xyz.com would end up going to abc.com
    This much of the problem has been resolved. Works a LOT better when you put the rules in the correct directory Sighhhhhhh

    The first part of the problem is still outstanding however.
    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •