Forum Moderators: phranque
I've gotten my host to turn on wildcard DNS for me and the follow code definitely works properly:
RewriteCond %{HTTP_HOST} images\.mydomain\.com [NC]
RewriteCond %{REQUEST_URI}!^/images/.*
RewriteRule (.*)/images/$1[L]
So if [images.mydomain.com...] is entered,
it transparently uses [mydomain.com...]
Now to attempt automatic mode, this does NOT work, help!
RewriteMap lowercase int:tolower
RewriteEngine on
RewriteCond ${lowercase:%{HTTP_HOST}}!^$
RewriteCond ${lowercase:%{HTTP_HOST}}!^www\.mydomain.com$
RewriteCond ${lowercase:%{HTTP_HOST}} ^(www\.¦)([^.]+)\.mydomain\.com$
RewriteRule ^(.+) ${lowercase:%{HTTP_HOST}}$1 [C]
RewriteRule ^(www\.¦)([^.]+)\.mydomain\.com.*) /$2$3 [L]
Yes it would. But let me first check the rules on my server. Once they work for me you could try them on your server. If they do not work there, then enabling RewriteLog [httpd.apache.org] will help indeed.
>>And what RewriteLogLevel is safe to use without
>>slowing down the serve?
RewriteLogLevel [httpd.apache.org] below 3 are ok. But they will not always yield enough information about what´s going on.
Let me finish dinner and I´ll test the rules ASAP ;)
Andreas
RewriteCond: input='aaron<->aaron' pattern='!^(.*)<->\1$' => matched
What is says is basically that what is on the left hand side of the <-> is not the same as what´s on the right hand side. BUT IT IS THE SAME!
Perl [perl.com] is on my side.
Perl [perl.com] -e '$_="aaron<->aaron"; print "+" if /^(.*)<->\1$/;'
will print +. I know that is no real proof since Perl [perl.com] uses Perl [perl.com] regular expressions while mod_rewrite [httpd.apache.org] uses POSIX regular expressions but I´m using only a subset that is equal in both.
And what´s really strange is that the even the earlier code that worked for amznVibe and me no longer works :o
I switched from Redhat to Debian and Apache [httpd.apache.org] 1.27 to 1.26 but never expected that there were such big differences.
RewriteEngine On
# Rewrite only when Host is not empty
RewriteCond %{HTTP_HOST}!^$
# Rewrite only when Host is not main domain
# Delete if there is no main server that is not subject to rewriting
#RewriteCond %{HTTP_HOST}!^server$ [NC]
# Extract domain (%1), tld (%2) and first two path elements (%3)
RewriteCond %{HTTP_HOST}<->%{REQUEST_URI} \.([^.]+)\.([^.]+)<->/([^/]+)?/?([^/]+)? [NC]
# Rewrite only when "tld/domain" not equal to first two path elements
RewriteCond %2<->%3!^(.*)<->\1$ [NC]
RewriteCond %1<->%4!^(.*)<->\1$ [NC]
# Rewrite to /subdomain/request
RewriteRule ^(.*) /%2/%1/$1 [L]
This code does work except that it will cause an endless loop. You might want to try it and see whether it goes into a loop. It shouldn´t and didn´t in my earlier code when testing on Redhat.
Andreas