"Rik" <luiheidsgoeroe@hotmail.com> schreef in bericht
news:e303$45828b3a$8259c69c$17649@news2.tudelft.nl ...
> HansH wrote:
> Yup, so:
> ServerName sub.example.com
> ServerAlias *.example.com
> Should work, no?
Yes, it does for me with version 2.2.3.
It is documented for 1.3 too ...
.... somehow I've skipped that page for over 7 years in a row
>> Only rewritemap ${MapName:LookupKey|DefaultValue } has a default.
>> However rewritemap is not available in .htaccess.
> Indeed, but also this should not be needed.
> The 'random' subdomains should be redirected to sub.example.com.
> There is absolutely no need to try to use mod_rewrite for this,
The rewritemap would return 'Default Value' for LookupKeys not listed.
Defaulting is part of your question and this single directive justs gets
closest.
> ... let alone RewriteMap :-).
You cannt use rewritemap in .htaccess ...
>> Feel free to test this
>> # set default for unkown
>> SetEnvIf site=subs
>> # set for each known
>> SetEnvIfNoCase Host www.domain.tld site=www
>> SetEnvIfNoCase Host 123.domain.tld site=123
>> SetEnvIfNoCase Host xyz.domain.tld site=xyz
>>
>> RewriteEngine on
>> RewriteRule ^/(.*)$ /%{ENV:site}/$1 \
>> [QSA,PT,E=DOCUMENT_ROOT:%{DOCUMENT_ROOT}%{env:SITE}/]
>>
>> I've never used the 'E=... 'this way, might work, may fail...
>> ... if it works, will give fully isolated subsites.
>
> Well, isolated is not where I'm after. If that's what I wanted, I would
> just create subdomains explicitly, which is a lot simpler :-).
It is my understanding your hoster is providing you ONE WILDCARD domain on a
shared host and you are attempting to virtualize that for some subdomains.
> I'm trying to take advantage of the wildcard, to have the 'internal'
> workings of a
> site exactly the same (page building, user logging, etc.), but the content
> all different from the database, based on the name of the subdomain. That
> way, I don't have to worry about creating subdomains, updating code on
> every single one, etc.
Try
RewriteRule ^/(.*)$ /yourscript.pqr?site=%{ENV:site}&request=$1 [QSA,PT]
Even then isolation may come in handy for images, stylesheets and
javasripts.
To use a single script accros all subdomains have subs/pages/.htacces and
www/pages/.htaccess rewrite the request to that script:
RewriteRule ^.*/(.*)$
%{DOCUMENT_ROOT}/../yourscript.pqr?site=%{ENV:site}&request=$1 [QSA,PT]
If your need to change, just modify one of the */pages/.htaccess to have
that one sub domain use another script.
HansH