httpd rewrite or redirect to subdomain

Discussion in 'Site & Server Administration' started by Holger Niklas Rosencrantz, Jul 18, 2010.

  1. #1
    How to achieve
    http://(www.)domain.com.br/vi/{N}.htm
    redirect or rewrite to
    http://web.domain.com.br/vi/{N}.htm
    ? I try for very long time and not right effect
     
  2. Shagoon

    Shagoon Notable Member

    Messages:
    596
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    220
    #2
    RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
    RewriteRule ^(.*)$ http://web.domain.com/$1 [R=301,L]
     
    Shagoon, Jul 18, 2010 IP
  3. Holger Niklas Rosencrantz

    Holger Niklas Rosencrantz Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Edit:
    Looking for all other URI equal(!), how to redirect only URI like eg
    http://domain.com.br/vi/9975.htm
    Code (markup):
    to
    http://web.domain.com.br/vi/9975.htm
    Code (markup):
    Tried all these
    Redirect /abc2.html http://web.domain.com.br [R=301,L]
    RedirectMatch permanent ^/anything/(.*)$ http://web.domain.com.br/$1
    RedirectMatch permanent ^/vi/(.*)$ http://web.domain.com.br/vi/$1
    RedirectMatch permanent ^/vi/?([0-9]+)\.htm$ http://web.domain.com.br/vi/$
    RewriteCond %{HTTP_HOST} ^www.domain.com.br/vi/$ [NC]
    RewriteRule ^(.*)$ http://web.domain.com.br/vi/$1 [R=301,L]
    Code (markup):
     
  4. garbin

    garbin Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i think .htaccess file can easy to resolve the problem. the code:

    RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
    RewriteRule ^(.*)$ http://web.domain.com/$1 [R=301,L]
     
    garbin, Jul 19, 2010 IP
  5. Holger Niklas Rosencrantz

    Holger Niklas Rosencrantz Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I too think that looks right. Hence trying this full set and reporting back how it goes while you may inspect www.montao.com.br/vi/{N}.htm still won't redirect to web...accordingly
    RewriteRule ^/vi/?([0-9]+)\.htm$ /Market/vi.do?id=$1 [PT,L]
    RewriteRule ^/li /Market/list.do [QSA,PT,L]
    RewriteRule ^/vi/locations.jsp /Market/locations.jsp [PT,L]
    Redirect /abc2.html http://web.montao.com.br [R=301,L]
    RedirectMatch permanent ^/anything/(.*)$ http://web.montao.com.br/$1
    RedirectMatch permanent ^/vi/(.*)$ http://web.montao.com.br/vi/$1
    RedirectMatch permanent ^/vi/?([0-9]+)\.htm$ http://web.montao.com.br/vi/$
    RewriteCond %{HTTP_HOST} ^www.montao.com.br/vi/$ [NC]
    RewriteRule ^(.*)$ http://web.montao.com.br/vi/$1 [R=301,L]
    Code (markup):
     
  6. Holger Niklas Rosencrantz

    Holger Niklas Rosencrantz Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    All that is missing to catch is the dot. Hence my wonder if the whole wanted effect can be done with RedirectMatch only since nearly the same redirect is doable already ie

    http://montao.com.br/vi/asd
    Code (markup):
    redirects to

    http://web.montao.com.br/vi/asd
    Code (markup):
    according to

    RedirectMatch permanent ^/vi/(.*)$ http://web.montao.com.br/vi/$1
    
    Code (markup):
    Now clearly what I want is
    http://montao.com.br/vi/{N}.htm
    Code (markup):
    redirects to

    http://web.montao.com.br/vi/{N].htm
    Code (markup):
    ie just add a subdomain to one dynamic uri. This should be easy or why not?
     
    Last edited: Jul 20, 2010
  7. Holger Niklas Rosencrantz

    Holger Niklas Rosencrantz Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Solved @stackoverflow(stackoverflow.com/questions/3237061/how-mod-rewrite-can-add-subdomain) thanking you so much