> >> My attempt was: >> >> RewriteEngine On >> RewriteRule ^(www\.)?domain\.ext/subdomain/(.*)$ >> subdomain\.domain\.ext/$2 [R=301,L] >> >> I now think this would be better: >> >> RewriteEngine On >> RewriteRule ^domain\.ext/subdomain/(.*)$ subdomain\.domain\.ext/$2 >> [R=301,L] > > No better. > > ... > > As Tom correctly stated, YOU WILL NEED A RewriteCond to match any > hostnames. > > ... > > Then carry on with your RewriteRule voodoo, taking care to note that you > CAN NOT use the domain name in a RewriteRule. > You guys are very patient in answering this Reese fellow! In any case, just one trick I have seen, to get around the "feature" you mention: include a rewrite rule that modifies the URL to insert the host name. For instance, rewriteCond $(HOST_NAME) www.domain.ext rewriteRule ^(.*)$ $(HOST_NAME)$1 rewriteRule regexpOnPartOfHostname toWhatever For Reese: the first rule will run only if the condition is true, and will insert the domain name before the URL path. Since the first rule always matches (when the condition is verified), it chains to the second rule. In the second rule, the regexp can now contain patterns matching parts of your domain. So you could have rewriteCond $(HOST_NAME) ^(.*)\.domain\.ext rewriteRule ^(.*)$ $(HOST_NAME)$1 rewriteRule ^(.*)\.domain\.ext(.*) domain.ext/$1$2 [R,L] The first rule only runs if the hostname of the query if for a subdomain, and inserts the hostname before the path. Then the next rule finds the part of the new URL (domain+URL) that contains subdomain name and URL path and reorders them into a new domain/subdomain+path (path always starts with a slash so no need for it). Can you interpret: rewriteCond $(HOST_NAME) ^(.*)\.domain\.ext rewriteRule ^(.*)$ $(HOST_NAME)$1 rewriteRule ^([a-z])(.*)([0-9])\.domain\.ext(.*) www$3.domain.ext/$2_$1$4 What will it do to the following HTTP requests: domain.ext/something asub2.domain.ext/something asub.domain.ext/something Your knowledge of regexp is the only limit in how much you can chop up your hostname to rewrite the URL. Oliver --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx