subdomain redirect to directory

Discussion in 'Apache' started by spidro, Sep 18, 2007.

  1. #1
    hi

    i'v added sub domain to my domain in cpanel
    forums.domain.com
    but when i type it in the address bar i see it redirect to domain.com/forums

    i never seen anything like this before so i'v no idea how to change it
    how can i change that

    Edit
    i just figured out this
    i'v this mod rewrite in my .htaccess to redirect www.domain.com to domain.com
    when i removed it the sub domain worked ok
    so how can make the subdomain work and redirect www.domain.com to domain.com ??

     
    spidro, Sep 18, 2007 IP
  2. Talker

    Talker Notable Member

    Messages:
    2,795
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    210
    #2
    Never seen that before myself..

    try deleting and adding the subdomain again.
     
    Talker, Sep 18, 2007 IP
  3. spidro

    spidro Well-Known Member

    Messages:
    877
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #3
    deleting and adding the subdomain again wont help i figured out what happed
    post edited
     
    spidro, Sep 18, 2007 IP
  4. spidro

    spidro Well-Known Member

    Messages:
    877
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #4
    i'm still having problem with the subdomain
    how can i redirect directory to subdomain
    domain.com/forums i wanna redirect it to forums.domain.com

    and in the same time i wanna redirect www.domain.com to domain.com
    i'm using mod rewrite
    but when i do that the subdomain doesn't work is there is any way i can make it work??
     
    spidro, Sep 19, 2007 IP
  5. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Here is a derivation of what I use - this also deals with wildcard subdomains

    RewriteCond %{HTTP_HOST} !^forum\.example\.com [NC]
    RewriteCond %{HTTP_HOST} ^(.+)\.example\.com [NC]
    RewriteRule (.*) http://example.com/$1 [R=301,L]

    Or you can simply use:

    RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
    RewriteRule (.*) http://example.com/$1 [R=301,L]
     
    krt, Sep 19, 2007 IP
  6. spidro

    spidro Well-Known Member

    Messages:
    877
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #6
    now it work thanks:)
     
    spidro, Sep 19, 2007 IP