This is a discussion on Wildcard subdmoains within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi all, just an sanity check from my part: AFAIK it should be possible in apache to set a subdomain ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi all,
just an sanity check from my part: AFAIK it should be possible in apache to set a subdomain as wildcard domain. So, in a virtualhost: ServerAlias the_target.example.com *.example.com And as long as an A record is set: *.example.com A 1.2.3.4 Every <random_string>.example.com should arriev at the virualhost that is configured, am I right? So I could define a subdomain in this particular vhost, and it;s not required to be the 'main' domain? I'd say this is right, unfoturnatly I'm not entirely sure as the only DNS records I can manipulate (and unfortunatly no vhosts manually) are with said hoster. Am I wrong (ohoh, apologies are in order..) or not? Am I missing something? Could it be because of further requiremens that I missed? Does anyone per chance know wether the fact I/the hoster uses Plesk makes any difference? Keep me sane, say I'm right :-) -- Rik Wasmus |
|
|||
|
"Rik" <luiheidsgoeroe@hotmail.com> schreef in bericht
news:de46$4580ebcd$8259c69c$9438@news2.tudelft.nl. .. > ServerAlias the_target.example.com *.example.com To the best of my knowledge ServerAliad DOES NOT take a wildcard ... .... and that is pesky -without an l- > > And as long as an A record is set: > *.example.com A 1.2.3.4 > > Every <random_string>.example.com should arriev at the virualhost that is > configured, am I right? So I could define a subdomain in this particular > vhost, and it;s not required to be the 'main' domain? AFAIK a name based vhost needs all valid alliasses spelled out. IP based has a chance to work using some rewriting... HansH |
|
|||
|
I am trying to use module_rewrite to solve your problem, but not success
yet. I am newbie to apache too. Maybe following will give you some hints #try to response http://AAA.example.com/test.htm with /AAA/test.htm RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ RewriteRule ^/(.*)$ /$1/$2 -- "Rik" <luiheidsgoeroe@hotmail.com> 写入消息 news:de46$4580ebcd$8259c69c$9438@news2.tudelft.nl. .. > Hi all, > > just an sanity check from my part: AFAIK it should be possible in apache > to > set a subdomain as wildcard domain. So, in a virtualhost: > > ServerAlias the_target.example.com *.example.com > > And as long as an A record is set: > *.example.com A 1.2.3.4 > > Every <random_string>.example.com should arriev at the virualhost that is > configured, am I right? So I could define a subdomain in this particular > vhost, and it;s not required to be the 'main' domain? |
|
|||
|
"Aray" <1@2.3> schreef in bericht news:elrbh0$lnb$1@news.cn99.com...
>I am trying to use module_rewrite to solve your problem, but not success >yet. I am newbie to apache too. > > Maybe following will give you some hints > > #try to response http://AAA.example.com/test.htm with /AAA/test.htm > RewriteEngine on > RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ > RewriteRule ^/(.*)$ /$1/$2 > An untested thought ... RewriteRule ^/(.*)$ /%1/$1 [QSA,PT] Still, AFAIK only functional for those FQDN specified with servername or serveralias witin a common vhost. HansH |
|
|||
|
HansH wrote:
> "Aray" <1@2.3> schreef in bericht news:elrbh0$lnb$1@news.cn99.com... >> I am trying to use module_rewrite to solve your problem, but not >> success yet. I am newbie to apache too. >> >> Maybe following will give you some hints >> >> #try to response http://AAA.example.com/test.htm with /AAA/test.htm >> RewriteEngine on >> RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ >> RewriteRule ^/(.*)$ /$1/$2 >> > An untested thought ... > RewriteRule ^/(.*)$ /%1/$1 [QSA,PT] > > Still, AFAIK only functional for those FQDN specified with servername > or serveralias witin a common vhost. Well, the .htaccess rewrite is the simple bit. Let's say I have a subdomain subs.example.com, to which I wish to direct all 'unknown' subdomains: RewriteCond %{HTTP_HOST} ^subs\.example\.com RewriteRule ^(.*)$ /choose.php?foo=$1 [QSA,L] RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?request=%1&foo=$1 [QSA,L] RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)$ $1?request=%i [QSA,L] -- Rik Wasmus |
|
|||
|
-- "HansH" <hansh@invalid.invalid> 写入消息 news:45813705$0$339$e4fe514c@news.xs4all.nl... > "Aray" <1@2.3> schreef in bericht news:elrbh0$lnb$1@news.cn99.com... >>I am trying to use module_rewrite to solve your problem, but not success >>yet. I am newbie to apache too. >> >> Maybe following will give you some hints >> >> #try to response http://AAA.example.com/test.htm with /AAA/test.htm >> RewriteEngine on >> RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ >> RewriteRule ^/(.*)$ /$1/$2 >> > An untested thought ... > RewriteRule ^/(.*)$ /%1/$1 [QSA,PT] > I tested this. It does works! use the following configuration: RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.aray\.com$ RewriteRule ^/(.*)$ /%1/$1 [QSA,PT] Use IE request this url http://a.aray.com/file/not/exsits.htm, following log will apears in access_log 192.168.255.254 - - [15/Dec/2006:09:18:37 +0800] "GET /a.htm HTTP/1.1" 304 - Use Ie request this url http://a.aray.com/file/not/exsits.htm, folling log will apears in access_log: 192.168.255.254 - - [15/Dec/2006:09:22:14 +0800] "GET /file/not/exsits.htm HTTP/1.1" 404 219 in error_log: [Fri Dec 15 09:22:14 2006] [error] [client 192.168.255.254] File does not exist: /usr/local/apache2.2/htdocs/a/file > Still, AFAIK only functional for those FQDN specified with servername or > serveralias witin a common vhost. > > HansH > > |
|
|||
|
-- "Rik" <luiheidsgoeroe@hotmail.com> 写入消息 news:d174a$4581fc3b$8259c69c$29310@news1.tudelft.n l... > Offcourse it does, however, it was not my problem :-). > > The point was to even arive at 'specific_subdomain.example.com' from > 'random_subdomain.example.com' Maybe, you can use module_rewrite to use files in "specific directory" to response the request wich has header "specific_subdomain.example.com". and all other request with header 'random_subdomain.example.com' not configured explicit use a file "invalid_domain.htm". Then, 'specific_subdomain.example.com' is arive from 'random_subdomain.example.com' Oops, my English is poor, I try hard to read your words, may misunderstand you. > -- > Rik Wasmus > > |
|
|||
|
Aray wrote:
>> Offcourse it does, however, it was not my problem :-). >> >> The point was to even arive at 'specific_subdomain.example.com' from >> 'random_subdomain.example.com' > > Maybe, you can use module_rewrite to use files in "specific directory" > to response the request wich has header Nonono. For the files in the specific directory to work, first we have to arrive THERE. That's the problem. Everything beyond that is a piece of cake :-). To illustrate, say I have in the document root of specific_sub.example.com this file: ----index.html----- <html> <head> <title>Wildcards</title> </head> <body> <p>This is specific_sub.example.com, but you may have reached it under another name</p> </body> </html> -------------------- Now what I want is that EVERY not specifically configured subdomain arrives here, and will show the same file. How I will distinguish how they got there is of no importance. This has to work, everything further is peanuts. -- Rik Wasmus |
| Thread Tools | |
| Display Modes | |
|
|