HansH wrote:
> "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
Well, as long as that works, my question is totally answered.
>>> 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.
The only 'defaulting' that's needed is to arrive at the particular
subdomain from a subdomain that's ot explicitly set, keeping the subdomain
in the browser window as is.
>> ... let alone RewriteMap :-).
> You cannt use rewritemap in .htaccess ...
I know, 't was a pain to write an alternative for toupper; without it some
months ago. Don't ask me why I needed it.... Something to do with backwards
compatibility with buggy code out of my control.
>>> 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.
It is indeed a shared host, but all other subdomains are explicitly set.
It's managed by Plesk, and in that configuration I can easily make new
subdomains to my harts desire. I don't have access to the XML api though,
and a project of mine requires the use of on the fly subdomains. The
scripts in those subdomains remain the same, only the content extracted
from the database and a single suitable named configuration file differ.
Unfortunately, I offcourse don't get permission to examine their total
configuration. I have to guess a lot :(.
>> 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]
RewriteMap is unfortunately not an option, and furthermore not needed as
this does same enough work as:
RewriteCond %{HTTP_HOST} !^explicit_subdomain\.example\.com
RewriteCond %{HTTP_HOST} !^([^.]+)\.example\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^{.*}$ /myscript.php?site=%1&request=$1 [QSA,L]
Wether a particular subdomain should or shouldn't exist is totally up to
the furthet script, which is quite capable of that.
I appreciate all suggestions about what to do with the request further on,
but that's all unneccesary, and easily figured out.
The main thing was the ServerAlias thing, and as far as I can gather, I was
indeed right about it's workings, so I'll contact my hoster and let them
explain in detail why they cannot ServerAlias to work (or maybe they
can...).
--
Rik Wasmus