Wildcard htaccess subdomain redirect, please help!

Discussion in 'General Scripting Chat' started by kimkils, Apr 15, 2010.

  1. kimkils

    kimkils Power Member

    Joined:
    Jan 10, 2009
    Messages:
    663
    Likes Received:
    225
    Ive been searching and testing for an hour now and i havent got any code to work...

    I want to redirect wildcard subdomains like so..


    whatever.mydomain.com

    to

    mydomain.com/page.php?whatever

    So with php i can use the passed keyword (in this case whatever)

    Please help, much rep and love in return! :):)
     
  2. webcatpl

    webcatpl Junior Member

    Joined:
    Aug 12, 2008
    Messages:
    102
    Likes Received:
    9
    First of all - make sure your .htaccess is enabled.

    Then you can try:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/%1 [QSA,R=301,L]
     
  3. kimkils

    kimkils Power Member

    Joined:
    Jan 10, 2009
    Messages:
    663
    Likes Received:
    225
    Last edited: Apr 15, 2010