doubi4531 2013-12-15 16:28
浏览 26
已采纳

PHP - 每个用户的子域名[关闭]

I have purchased a domain name which I have assigned an a name record to my Ubuntu web server. On the server each user has their own profile located at /var/www/user, each user has a sub directory. I need a sub domain for each user in the /user directory.

I started by giving the domain a wildcard '*' a name record which points to the server (as well as @ (obviously)). Then with a Virtual Host I use the wildcard to check for any requests to a sub domain and set their document root to a redirect directory /var/www/redirect. So essentially I'm filtering out sub domain requests and then sending them to the redirect directory to explode the sub domain they requested and forward appropriately.


My problem lies with trying to get the original sub domain they requested so I can explode the string and find the user they need and redirect. Does anyone know how I can do this? Should I pass it as a GET variable from Virtual Host or is there a better way?


If this sounds like a bad design I'd highly appreciate it if you could suggest a better one!

  • 写回答

1条回答 默认 最新

  • dongpan1416 2013-12-15 16:34
    关注

    The original sub domain they requested is in $_SERVER['HTTP_HOST'].

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?