通配符DNS和虚拟子域?

时间:2009-09-29 20:41:56

标签: php virtual subdomain wildcard-subdomain

我只是不明白..

我计划得到这样的场景:username.mydomain.com = mydomain.com/user.php?user=username

好吧,让我们走得那么远,因为这个通配符DNS让我疯了! :/

我有DNS记录

* A my-ip-address

我的vhost文件中有

ServerAlias *.mydomain.com

但它根本不起作用..没有等待,例如test.mydomain.com正在运行,但没有任何随机子域.. Wut?

当我ping任何子域时,它会发现我的ip应该是这样的。任何人都可以帮助我吗?

Okey然后是另一个问题。何时(以及如果)我将使这个虚拟子域工作,最好的解决办法是让它像我上面解释的那样工作?

username.mydomain.com等于mydomain.com/user.php?user=username

但是用户可以看到它就像它是子域名一样......在这里很少丢失,sry! :)

感谢您的帮助!

3 个答案:

答案 0 :(得分:2)

刚刚处理了同样的情况

你需要做的是

  • 转到cpanel中的高级DNS区域编辑器
  • 选择域名
  • 姓名:* .doaminname.com
  • TTL:14400
  • 输入:CNAME
  • 地址:domainname.com/path
  • 所以,它会像:* .doaminname.com CNAME 14400 domainname.com/path

然后在.htaccess中进行一些调整

# Extract the subdomain part of domain.com
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domainname\.com$ [NC]

# Check that the subdomain part is not www and ftp and mail
RewriteCond %1 !^(www|ftp|mail)$ [NC]

# Redirect all requests to a php script passing as argument the subdomain
RewriteRule ^.*$ http://www.domainname.com/path/%1 [R,L]

这里%1是子域位。

希望,这有助于其他身体在这种情况下失去其他身体。感谢。

答案 1 :(得分:0)

我刚刚意识到它......我总是使用..

  • CNAME abc.com。

http://www.decodephp.com/2006/10/12/virtual-subdomains-and-php/

答案 2 :(得分:0)

Okey我不知道刚刚发生了什么,但我对这种情况非常生气,修复了我的VPS并重新安装整个系统......现在它正在工作...... :)

无论如何,谢谢Sab!

相关问题