302 redirect

Discussion in 'Apache' started by wil888, Sep 1, 2007.

  1. #1
    wil888, Sep 1, 2007 IP
  2. evera

    evera Peon

    Messages:
    283
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    with something like this:

    Options +FollowSymLinks 
    
    RewriteEngine On 
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC] 
    RewriteRule .* http://www.example.com%{REQUEST_URI} [R=301,L]
    RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC] 
    RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC] 
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteRule ^(.*)$ /%2/$1 [QSA,L]
    Code (markup):
    it will redirect www.example.com/test/ and example.com/test/ to test.example.com

    Not tested ;)
     
    evera, Sep 10, 2007 IP