Im checking the "validity" (if is authorized to make something) of a domain trying to retrieve it from my database, the url came to my script over a GET var and then i just query the database:
$url = $_GET['url']; // complete url of the site like: sub1.domain.com/page/1/some
$url = parse_url($_GET['url']); // parsing the url http://php.net/manual/en/function.parse-url.php
$host = $url['host']; // gives me sub1.domain.com
After parsing:
$query = "SELECT * FROM domains_table WHERE domain = '" . $host . "'";
This works great, the think is sometimes domain.com have many sub domains and I cant save in database all the variations. It seems to me a lost of space if lets say domain.com have 30 sub domains and then I need to save sub1.domain.com sub2.domain.com and so...
Instead I was thinking in a more smart way, like saving in data base just *.domain.com and then somehow (and this is where i need help) in the query or in the php script (better if is in the query, personal taste) create something that tells * could be any string. How can i do this?
EDIT:
There is some confusion in the answers so I try to explain better my self:
If i have in my table saved on the url field: *.domain1.com how can i make something like this:
SELECT * FROM domain WHERE url LIKE "sub1.domain.com"
To retrieve something.