A complex .htacces

Discussion in 'Apache' started by upalc, Sep 25, 2012.

  1. #1
    I need the code for a .htaccess file that satisfies the following condition...

    if($url == http://jolchobi.com)
    {
    redirect to http://www.jolchobi.com
    }
    else if($url == http://jolchobi.com/*)
    {
    redirect to http://ecards.cjolchobi.com/*
    }

    i.e. in simple english...

    naked domain http://jolchobi.com or http://jolchobi.com/ will be redirected to http://www.jolchobi.com

    if there is anything after jolchobi.com, e.g. http://jolchobi.com/fairy.php or http://jolchobi.com/chobi.php?c=mhl&p=004.jpg&t=Subho+Mahalaya.+Pujo+valo+katuk. will be redirected to http://ecards.jolchobi.com/fairy.php or http://ecards.jolchobi.com/chobi.php?c=mhl&p=004.jpg&t=Subho+Mahalaya.+Pujo+valo+katuk. respectively...
     
    upalc, Sep 25, 2012 IP
  2. plussy

    plussy Peon

    Messages:
    152
    Likes Received:
    5
    Best Answers:
    9
    Trophy Points:
    0
    #2
    not sure if it works or nor but you can try this

    
    RewriteEngine on
    
    
    RewriteCond %{REQUEST_URI} ^.+ [NC]
    RewriteRule (.*) http://ecards.jolchobi.com/$1 [R=301,L]
    
    
    RewriteCond %{HTTP_HOST} ^jolchobi\.com [NC]
    RewriteRule (.*) http://www.jolchobi.com/$1 [R=301,L]
    
    Code (markup):
     
    plussy, Sep 27, 2012 IP
  3. upalc

    upalc Active Member

    Messages:
    189
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    78
    #3
    Thanks for the code. But this was not working :(

    Have done it using PHP...
     
    upalc, Oct 3, 2012 IP