RewriteRule for Domains and Subdomains

Discussion in 'Apache' started by aN00Bis, Jan 26, 2010.

  1. #1
    I'm working on some rewrite procedures for my websites.
    Here's what I'm trying to get the htaccess file to do:

    www.domain1.com/* -> /domain1.com/www/*
    sub.domain1.com/* -> /domain1.com/sub/*
    www.domain2.com/* -> /domain2.com/www/*
    sub.domain2.com/* -> /domain2.com/sub/*
    Code (markup):
    etc...

    and also:

    www.domain1.com/shared/* -> /_shared/*
    www.domain2.com/shared/* -> /_shared/*
    Code (markup):
    etc...

    so here's what I have in my htaccess file so far:

    RewriteEngine	on
    
    # Shared Folder Rename
    RewriteCond %{REQUEST_URI} ^/shared/([^.]*)
    RewriteRule ^/shared/(.*)$ /_shared/$1
    
    # Global Domain Rename
    RewriteCond %{REQUEST_URI} !^/shared/([^.]*)
    RewriteCond %{HTTP_HOST} ^([^.]+)\.([^.]+)\.([^.]+)
    RewriteRule ^(.*)$ /%2.%3/%1/$1
    Code (markup):
    if I keep this in my httpd.conf file, everything works well
    if I move it to the htaccess file in the root directory, i get loop errors:

    [I]Request exceeded the limit of 10 internal 
    redirects due to probable configuration error.[/I]
    Code (markup):
    Does anyone have any ideas what is going wrong?
     
    aN00Bis, Jan 26, 2010 IP