Problem redirecting Wildcard subdomain

Discussion in 'Site & Server Administration' started by belgin fish, Jun 29, 2009.

  1. #1
    Hey, well I'm trying to redirect a wildcard subdomain, *.belginfish.com to http://www.belginfish.com

    For some reason, when i add the redirection through cpanel its giving me this error:

    Apache detected an error in the Rewrite config.

    Syntax error on line 17 of .htaccess.hbsja7z_zfF8mKXFKyNohohIURgEhBs3:
    RewriteCond: cannot compile regular expression '^*.belginfish.com$'

    Please try again.

    Could anyone tell me why i would be getting this? My host allows wildcard domains,

    Thanks
     
    belgin fish, Jun 29, 2009 IP
  2. vasyl

    vasyl Peon

    Messages:
    138
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use \. instead of just .
     
    vasyl, Jun 30, 2009 IP
  3. belgin fish

    belgin fish Well-Known Member

    Messages:
    1,544
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    185
    Digital Goods:
    2
    #3
    It doesn't allow me to create it when i do that.
     
    belgin fish, Jun 30, 2009 IP
  4. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #4
    Add the following lines to your .htaccess file:

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.belginfish\.com
    RewriteRule (.*) http://www.belginfish.com/$1 [R=301,L]
     
    RoseHosting, Jun 30, 2009 IP