Koozali.org: home of the SME Server

Wildcard hostnames

Offline beast

  • *
  • 245
  • +0/-0
Wildcard hostnames
« on: April 06, 2010, 09:25:49 PM »
Hi Everyone

Is it possible to setup wildcard catch for hostnames on an Ibay?

E.g. something like *.mydomain.xxx that will catch aaa.mydomain.xxx and also b.mydomain.xxx and direct it to the same ibay.

I know I can setup a specific hostname like www.mydomain.xxx in server-manager under hostnames and addresses but how do I set it up to catch anything in front of the ibay domain name (can also be the primary ibay if only possible this way).

What I like to end up with is to be able to detect the random part of the url in PHP (know how to do that part)

Thank you

NB: I have searched the forum and documentation for this with no results (it still might be there anyway)

Offline Curly

  • ****
  • 114
  • +0/-0
Re: Wildcard hostnames
« Reply #1 on: April 06, 2010, 09:49:24 PM »
If you wouldn't configure the domain names, all the requests would go to the primary ibay. You could add an apache rewrite rule in the .htaccess file that could check the requested url and do a redirect.

Something like:

RewriteCond %{HTTP_HOST} ^(.*.)?.mydomain.xxx$
RewriteRule ^(.*) http://www2.mydomain.xxx/$1 [R=301,L]

Of course you would also redirect www.mydomain.xxx, so the RewriteCond should be a little more extended.
.......................................

Offline beast

  • *
  • 245
  • +0/-0
Re: Wildcard hostnames
« Reply #2 on: April 07, 2010, 12:45:26 AM »
If you wouldn't configure the domain names, all the requests would go to the primary ibay. You could add an apache rewrite rule in the .htaccess file that could check the requested url and do a redirect.

One of my servers does not show the primary ibay if I look up qwerty.domain.xxx another one does and the DNS is set up in the same way ???? And for sure the server that does not - is the one I need this behavior on  :-D  In stead it shows an error telling me that the page does not exist.

If only I was able to get the same behavior then I could move around the Ibay in question and the primary to make it behave as I need it to!

As far as I understand your solution it may be what I need - if only the server behaved correctly

Offline beast

  • *
  • 245
  • +0/-0
Re: Wildcard hostnames
« Reply #3 on: April 07, 2010, 12:51:21 AM »
RewriteCond %{HTTP_HOST} ^(.*.)?.mydomain.xxx$
RewriteRule ^(.*) http://www2.mydomain.xxx/$1 [R=301,L]

Of course you would also redirect www.mydomain.xxx, so the RewriteCond should be a little more extended.

This will not work as I will be unable to detect what is in front of mydomain.xxx in PHP - you redirect to a fixed page

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Wildcard hostnames
« Reply #4 on: April 07, 2010, 09:02:25 AM »
No, the $1 should add the requested URL relative to the original root URL, so this is not a redirect to a fixed page.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)