redirect with exception for subdomain

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • liuu
    New Member
    • Feb 2010
    • 1

    redirect with exception for subdomain

    I have modified the code and am close, just one small problem.

    What I have is this directory structure:

    public_html
    subDirA (This is where the website for example.com resides and is internally rewritten to public_html. The user never sees subDirA.

    subDirB (This is actually the new subdomain. Internally it looks like a subdirectory under public_html. In the code below, the subdomain displays as subDirB.example .com which is what I want and it no longer is being rewritten to subDirA. So this is working the way I want now.)

    subsubdir (This is a subdirectory under subDirB.example .com. This needs to be internally rewritten back to subDirB.example .com . This is the problem. I can not make this happen. It is still being displayed as subDirB.example .com/subsubDir instead of subDirB.example .com.


    Here is the latest code where everything works right except the internal rewrite of subsubdir back to http://subDirB.example.com

    I messed up subsubDirlainin g my problem. I have modified the code and am close, just one small problem.

    What I have is this directory structure:

    public_html
    subDirA (This is where the website for example.com resides and is internally rewritten to public_html. The user never sees subDirA.

    subDirB (This is actually the new subdomain. Internally it looks like a subdirectory under public_html. In the code below, the subdomain displays as http://subDirB.example.com which is what I want and it no longer is being rewritten to subDirA. So this is working the way I want now.)

    subsubdir (This is a subdirectory under http://subDirB.example.com. This needs to be internally rewritten back to http://subDirB.example.com . This is the problem. I can not make this happen. It is still being displayed as http://subDirB.example.com/subsubDir instead of http://subDirB.example.com.


    Here is the latest code where everything works right except the internal rewrite of subsubdir back to http://subDirB.example.com

    Code:
    AddHandler server-parsed .htm .html
    #
    Options +FollowSymLinks 
    RewriteEngine On
    RewriteBase /
    #
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC] 
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteRule ^(.+/)?index\.(php|html?)$ http://example.com/$1 [R=301,L] 
    # 
    RewriteCond %{HTTP_HOST} ^subDirB\.example\.com [NC] 
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteRule ^(.+/)?index\.(php|html?)$ http://subDirB.example.com/$1 [R=301,L] 
    #
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteRule ^subDirA(/(.*))?$ http://example.com/$2 [R=301,L] 
    # 
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteCond %{HTTP_HOST} ^subDirB\.example\.com [NC] 
    RewriteRule ^subsubDir(/(.*))?$ http://subDirB.example.com/$1 [R=301,L] 
    # 
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC] 
    RewriteCond %{HTTP_HOST} !^example\.com$  [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] 
    # 
    #RewriteCond %{HTTP_HOST} ^(www\.)?subDirB\.example\.com [NC] 
    #RewriteCond %{HTTP_HOST} !^subDirB\.example\.com$ [NC]
    #RewriteRule ^(.*)$ http://subDirB.example.com/$1 [R=301,L] 
    # 
    RewriteCond %{HTTP_HOST} !^subDirB\.example\.com$ [NC]
    RewriteRule !^subDirA(/.*)?$ /subDirA%{REQUEST_URI} [QSA,L] 
    #
    RewriteCond %{HTTP_HOST} ^subDirB\.example\.com$ [NC]
    RewriteRule !^subsubDir(/.*)?$ /subsubDir%{REQUEST_URI} [QSA,L] 
    #
    #
    ErrorDocument 404 /missing.html
Working...