Forum Moderators: phranque
now,it's i have writen:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[a-z0-9\-]+\.example\.com$
RewriteRule ^/(.*)$ /%{SERVER_NAME}/$1
RewriteRule ^/([a-z0-9\-]+)\.example\.com/(.*)$ /$1/$2 [L]
RewriteRule ^.*$ /index.php [L]
I writen it in the httpd.conf ,it can work but I written in the .htaccess it didn't work,why?
the log error is:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
please help me,thank you!
<Use example.com please
See Forum Charter [webmasterworld.com]>
[edited by: tedster at 4:21 am (utc) on Dec. 23, 2006]
RewriteEngine on
RewriteCond %{ENV:rwdone} !^yes$
RewriteCond %{HTTP_HOST} !www\.example\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9\-]+)\.example\.com
RewriteRule (.*) /%2/$1 [E=rwdone:yes,L]
So, the first RewriteCond prevents repeated rewriting if rwdone has already been set to "yes".
The second RewriteCond prevents rewriting requests for the "www" subdomain.
The third RewriteCond captures the subdomain name into local variable %2, and also allows (but does not require) the subdomain name to be preceded by "www." in case of type-in addresses like "www.subdomain.example.com".
The RewriteRule then takes the requested URL path in $1 and prepends the subdomain name from %2, forming the rewritten URL-path. It also sets the environment variable "rwdone" to "yes" so that this rule will not be applied on the next mod_rewrite pass through your .htaccess code.
Thanks to member rkrause for the tip on avoiding "subdirectory obscuration."
In .httpd.conf, the code can be much simpler:
RewriteCond %{HTTP_HOST} !www\.example\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9\-]+)\.example\.com
RewriteRule [b]^/([/b].*)$ /%2/$1 [L]
but when i use the code:
the error is:
[Sat Dec 23 13:33:35 2006] [error] [client 219.***.133.105] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
why?
and i upload the .htaccess file to the space, the rewrite can't work,
the *.example.com all go to the root/index.html why?
[edited by: jdMorgan at 5:45 am (utc) on Dec. 23, 2006]
[edit reason] Obscured personal IP address [/edit]