简体   繁体   English

在PHP中使用一个站点用于多个域

[英]Using one site for multiple domain in PHP

I have one site completely working for one client , now I have some more clients want same thing replicated for them , Is there any way , that I can use this site as base site , as I plan to access this site from there domain and providing database for each client. 我有一个网站完全为一个客户端工作,现在我有一些客户想要为他们复制相同的东西,有什么办法,我可以使用这个网站作为基站,因为我打算从那里访问该网站并提供每个客户的数据库。

I am using PHP and MYSQL. 我正在使用PHP和MYSQL。 Thanks for any support , I appreciate your point of view also in this process. 感谢您的支持,我也感谢您在此过程中的观点。 do I have right approach 我有正确的方法吗?

I have been told that there will be SEO issues if I use one site for multiple domain. 我被告知如果我将一个站点用于多个域,将会出现SEO问题。 I have no competent person available which can direct me on domain name linking. 我没有合格的人可以指导我进行域名链接。 I have www.xyzuniversity.com and 85% data is fetching from database. 我有www.xyzuniversity.com,85%的数据来自数据库。 now i have to create abcuniversity.com and I want that I just create new database and ready to use and I think I can make multiple sites like this , if I succeed 现在我必须创建abcuniversity.com,我希望我只是创建新的数据库并准备好使用,我想我可以制作这样的多个网站,如果我成功的话

Thanks 谢谢

You can point multiple domains to the site. 您可以将多个域指向该站点。 You can get the domain name from the server vars ( $_SERVER['HTTP_HOST'] ) and choose you database through that. 您可以从服务器变量获取域名( $_SERVER['HTTP_HOST'] )并通过它选择数据库。 Make sure you dont have any absolute links. 确保你没有任何绝对的链接。

Put the shared code into a shared directory and give each domain it's own database configuration, so the database configuration is not shared. 将共享代码放入共享目录并为每个域提供自己的数据库配置,因此不共享数据库配置。

Then start your application with the different configuration based on the domain, eg by server environment variables like the hostname. 然后使用基于域的不同配置启动应用程序,例如通过主机名等服务器环境变量。

If your design does not support a configuration that can be injected into the application, you need to maintain two code-bases, one for each domain, eg in source-code control with one branch per domain. 如果您的设计不支持可以注入应用程序的配置,则需要维护两个代码库,每个域一个,例如源代码控制,每个域一个分支。

However I suggest that your code is that modular that it supports configuration for the parts that need configuration according to your needs. 但是我建议您的代码是模块化的,它支持根据您的需要配置需要配置的部件。 If it's not yet, think about coming closer to it and make the changes. 如果还没有,请考虑更接近它并进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM