|
Posted by Ja NE on 03/19/07 13:22
I would like to offer my registered users to have very short uri for
their pages in our comunity site, so I have enabled wildcard dns
*.bellay.com. and added virtaul host for it. (I'm testing this on one
domain I don't use so no harm will be done in testing time). and that is
working. than I tried to write mod_rewite rule in .htaccess which should
redirect anything.bellay.com to bellay.com/index.php?user=anything but I
failed.
rewriteEngine On
rewriteCond %{HTTP_HOST} !^$
rewriteCond %{HTTP_HOST} !^(www\.)?bellay\.com$ [NC]
rewriteCond %{HTTP_HOST}<->%{REQUEST_URI} ^(www\.)?([^.]+).*<->/([^/]+)
[NC]
rewriteCond %2<->%3 !^(.*)<->\1$ [NC]
rewriteRule ^(.+) /%2/index\.php\?user\=$1 [L]
so, I delitet those lines from .htaccess file and in my index.php, I put
on very top:
$server_host = explode('.', $_SERVER['HTTP_HOST']);
$subdomain = strtolower($server_host[0]);
$not_users = "/\b(www|ftp|dev|mail|smtp|pop|server|localhost|root)\b/i";
if (preg_match($not_users,$subdomain)) {
echo" header(\"Location: http://bellay.com/\");";
}
else {
echo" header(\"Location:
http://bellay.com/?user=$subdomain\");";
}
and that is working, but, before I implement that on my real site, I
have to ask if there is any bettar way to do that? are there any
drowbacks or potential (security) dangerous waitnig for me?
thank you very much.
Navigation:
[Reply to this message]
|