I'm working on a webpage, and I plan to offer content for multiple users on the same site. What I plan to do is have http://www.mysite.com which will display an index of all users, and also have user.mysite.com which will direct to the users content. I want the banner to vary depending on which way you access the site (or what content you are accessing), so it can display "My Site" or "User's site"
Thank you to anyone that can help.
Banner that changes depending on how a site is accessed?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
for real subdomains:for redirector based:
Code: Select all
<?php
$site = preg_replace("|^([^\.]+?).*?$|","\\1",$_SERVER['HTTP_HOST']); // get everything before the first dot
switch($site)
{
case 'jimmy':
// 'jimmy' specific banner(s) and content settings
break;
case 'jane':
// 'jane' specific banners(s) and content settings
break;
default:
// if the user isn't known or if it's http://www.mysite.com
// do generic banner(s) and content settings
break;
}
// all other code down here
?>Code: Select all
<?php
$site = explode('/',$_SERVER['REQUEST_URI']);
if(sizeof($site) >= 1)
$site = $site[1];
else
$site = '';
switch($site)
{
case 'jimmy':
// 'jimmy' specific banner(s) and content settings
break;
case 'jane':
// 'jane' specific banners(s) and content settings
break;
default:
// if the user isn't known or if it's http://www.mysite.com
// do generic banner(s) and content settings
break;
}
// all other code down here
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
outside a logic error in my regex it worked perfectly fine for me..
post your code if you continue to have an error...
Code: Select all
preg_match("|^([^.]+?)\.|",$_SERVER['HTTP_HOST'],$site); // get everything before the first dot
$site = $site[1];