Knowledgebase

grabbing part of a domain from a wildcard

Posted by DediPath, 12-23-2007, 01:53 PM
Ok I have a wildcard setup on my domain. Now I'm going to assign users subdomains (in actuallity there not) but I want to know how to grab the username out of the domain. Like so username.domain.com How would I grab that with PHP?

Posted by Renard Fin, 12-23-2007, 03:47 PM
normally, no ?

Posted by Barti1987, 12-23-2007, 06:05 PM
Peace,

Posted by DediPath, 12-26-2007, 12:26 AM
I'm talking about grabbing the USERNAME part of username.domain.com

Posted by abluegrape, 12-26-2007, 07:14 AM
How about something like: Thats off the top of me head - should work. Ry

Posted by DediPath, 12-26-2007, 01:48 PM
This is the current URL not just some domain i'm supplied with. I need it to grab the domain itself.

Posted by jmichalicek, 12-26-2007, 03:24 PM
You've been given a solution to grab the full domain/hostname already, right? And you've been given a solution to split that string so that it gets just the bit that you want, right? So combine those two concepts/techniques together and you've got your solution.

Posted by DediPath, 12-27-2007, 02:00 PM
That way errors out but If I do this it works. But the only problem is I don't think you can use . i nthe split function because it's supposed to use regexp. I don't know how to match it to a period.

Posted by jmichalicek, 12-27-2007, 02:18 PM
Backslash should escape special characters like '.' in regular expressions. If it's working, though, then I would think that it understands the way it is written just fine. If you're unsure, the best way to find out is to go have a look at the php documentation on split() and see what it says.

Posted by DediPath, 12-27-2007, 02:23 PM
It's not working, and i've been looking at the documentation thats how I know it needs regexp.

Posted by jmichalicek, 12-27-2007, 02:36 PM
I'm not a php developer, so I'm basing this guess on examples I've seen. Try changing split('\.',$_SERVER["HTTP_HOST") to split("\.",$_SERVER["HTTP_HOST"). If that doesn't do the trick, try this: explode(".",$_SERVER["HTTP_HOST"]) and see if that helps.

Posted by DediPath, 12-27-2007, 02:49 PM
thank you the \. worked.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
is cloud hosting? (Views: 605)


Language:

Client Login

Email

Password

Remember Me

Search