duangongqiong6958 2015-09-23 14:06
浏览 46
已采纳

通过子域处理多个站点

I'm trying to improve my skills in PHP by creating my own CMS infrastructure, probably based on a lightweight framework like FuelPHP.
Because I think it's better to have a goal, I would like to use this opportunity to build a multi site CMS.

It would be a CMS for a game.
Basically, here the workflow:

Somebody create an account on the main site (http://www.mainsite.com), then create a site for his server (http://my-beautiful-server.mainsite.com). People from his server would then come to the subdomain and register to interact with the forum, the gallery, updating their account, etc.

Is using subdomains a correct approach ?
If I use a wildcard for my DNS, how must the vhost be configured to redirect on the correct folder based on the subdomain ? Can I not use a folder system for each site and use only one app to handle everything by just "passing" the subdomain as a variable to the app to tell it on which site I am ? Is it reliable ?

If in the future I want to propose custom domain names, is it possible with this approach ? I would only need to handle domain name registering myself and add a vhost configuration to redirect on the correct folder ?

I'm a little lost on the correct and most robust approach.

Today I have the domain name and I will take a little VPS for testing.

Thanks a lot for any help to guide me in the good direction and sorry for my broken english, I had trouble finding ressources on the Internet.

  • 写回答

1条回答 默认 最新

  • douling8087 2015-09-23 14:10
    关注

    Is using subdomains a correct approach ?

    It is a perfectly acceptable approach.

    If I use a wildcard for my DNS, how must the vhost be configured to redirect on the correct folder based on the subdomain ?

    You use a default vhost to capture all the requests for the different hostnames.

    Then you can shuffle them around using mod_rewrite or by examining the requested hostname at the application level.

    Can I not use a folder system for each site and use only one app to handle everything by just "passing" the subdomain as a variable to the app to tell it on which site I am ? Is it reliable ?

    Yes.

    The variable will already be available to your PHP via $_SERVER['HTTP_HOST'].

    If in the future I want to propose custom domain names, is it possible with this approach ?

    Yes. There is no practical difference between a domain name and a subdomain as far as a webserver is concerned.

    I would only need to handle domain name registering myself and add a vhost configuration to redirect on the correct folder ?

    You wouldn't even need a specific vhost configuration. Your default one would suffice.

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

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探