Can I create a subdomain site on the same server as my top level
I have tried to figure this out, but the only thing I can come up with is I need a separate server.
I want to create a开发者_开发问答 mobile site for my existing site. I use zoneedit.com which allowed me to create mydomain.com and m.mydomain.com. My UI is completely (with a few exceptions) driven by css. I want to use the functionality from my top level with a different css file for my mobile subdomain site. But, the only way I see it working is if I created a new server for the mobile site. The only reason I say this is because if I redirect the user who is on a mobile device to m.mydomain.com and simply change the css then it is pointless for me to have a m.mydomain.com address. Right?
My question is basically can I have a different css file depending on the domain not the browser?
I really hope that makes sense!
Thanks, Craig
It's possible to do this on the same server:
- One strategy is URL rewrites based on hostname.
- Another is to have the same webroot for the server but point the location for the css directory to another on-disk location
- A third is to serve the stylesheet with a scripting language that inspects the HTTP host header.
In response to the comment by OP: The simplest solution is:
// Given that $browserIsMobile is a boolean set by the script
if( $browserIsMobile && $_SERVER['HTTP_HOST'] == 'm.example.com' )
send_mobile_stylesheet();
else
send_desktop_stylesheet();
精彩评论