每个用户的子域 [英] Subdomain for each user

查看:48
本文介绍了每个用户的子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有一个网站,该网站为每个注册用户提供了一个专用空间,如下所示: www.mywebpage.com/user1www.mywebpage.com/user2www.mywebpage.com/user3 在该路径内,用户拥有他的迷你网站.

I own a website which gives every registered user a dedicated space like this: www.mywebpage.com/user1 www.mywebpage.com/user2 www.mywebpage.com/user3 Inside this path the user has his mini web site.

我想给用户的路径不是我的域内的路径,而是这样的二级域: user1.mywebpage.comuser2.mywebpage.comuser3.mywebpage.com

I'd like to give my users not a path within my domain, but a second level domain like this: user1.mywebpage.com user2.mywebpage.com user3.mywebpage.com

很多网站都这样做,但是我不知道如何获得它!

A lot of websites do this, but I can't figure out how to get it!

  1. 我应该在每个用户的dns记录中注册一个CNAME吗?我怎么能用PHP做到这一点?我认为不可能用人工编写的脚本来配置Godaddy.

  1. Am I supposed to register a CNAME in my dns record for every single user? How the hell can I achieve this with PHP? I don't think it's possible to configure godaddy with a human-hand written script.

我可以注册一个别名CNAME,该别名将每个第二级域指向我的顶级域,然后在我的顶级域中检查检索用户的url的第一个标记:但是现在我无法在新页面(这是他的子站点的索引),否则我将丢失网址为userx.mywebpage.com的网址.

I may register an alias CNAME which points every second level domain to my top domain, and then check within my top domain the first token of the url retrieving the user: but now I can't redirect him on a new page (which is the index of his subsite) or I'd lost the web url userx.mywebpage.com.

我该如何处理?对于实现我的目标的正确方法的任何提示,我将不胜感激.

How can I handle this? I'd appreciate any hint about the right path to follow in order to achieve my goal.

推荐答案

  1. 创建通配符指向服务器IP的记录( *.mywebpage.com ).

ServerName * .mywebpage.com 创建一个Apache虚拟主机,将所有请求指向相同的文档根目录.您的脚本将查看主机名,以了解它是哪个用户的站点.您不需要重定向到用户的子域之外.如果您的脚本看到子域是"www",则这是您的特殊情况,在其中显示主网站而不是用户的资料.

Create an Apache virtual host for ServerName *.mywebpage.com, pointing all requests to the same document root. Your script looks at the hostname to know which user's site it is. You do not need to redirect outside of the user's subdomain. If your script sees the subdomain is "www", that's your special case where you display the main website instead of the user's stuff.

这篇关于每个用户的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆