.htaccess help

Discussion in 'Programming' started by riya_senk, Aug 29, 2007.

  1. #1
    I need to create subdomain redirect with .htaccess but I do not know how to do it. I exactly want

    http://[B]xyz[/B].mydomain.com to http://www.mydomain.com/page=xyz

    Can any one advise me rewrite tags about it?
     
    riya_senk, Aug 29, 2007 IP
  2. mckST

    mckST Banned

    Messages:
    159
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This should work fine for you.
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ([^.]+)\.mydomain.com [NC]
    RewriteRule ^(.*) http://mydomain.com/index.php?page=%1 [P]
    
    Code (markup):
    Not tested.

    mckST
     
    mckST, Aug 29, 2007 IP
  3. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #3
    You may have to do it through your CPanel if you do not have complete control over the domain / site.

    If so goto your cpanel, then goto Subdomains, and your there
     
    m0nkeymafia, Aug 29, 2007 IP
  4. riya_senk

    riya_senk Well-Known Member

    Messages:
    2,014
    Likes Received:
    174
    Best Answers:
    0
    Trophy Points:
    160
    #4
    Not working :(

    Can any one Help me?
     
    riya_senk, Sep 10, 2007 IP
  5. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #5
    what error do you get?
    try page=$1 instead of %1

    if you get 404 its probably a spelling mistake or something to do with the page its lookin up, if its an internal server error then its the rule itself
     
    m0nkeymafia, Sep 10, 2007 IP
  6. riya_senk

    riya_senk Well-Known Member

    Messages:
    2,014
    Likes Received:
    174
    Best Answers:
    0
    Trophy Points:
    160
    #6
    I changed $1 with %1 and page is ok but still getting 404 error.
     
    riya_senk, Sep 10, 2007 IP
  7. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #7
    here is the code i use:
    maybe worth trying it instead

    
    RewriteCond %{HTTP_HOST} ^www.xxx.com
    RewriteRule (.*) http://xxx.com/$1 [R=301,L]
    
    Code (markup):
     
    m0nkeymafia, Sep 11, 2007 IP