我可以动态创建子域(PHP,的.htaccess)与GoDaddy主机?

编程入门 行业动态 更新时间:2024-10-19 01:22:22
本文介绍了我可以动态创建子域(PHP,的.htaccess)与GoDaddy主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用的.htaccess和PHP相结合,以创建子域上我的GoDaddy的托管帐户上的动态。我碰到试图修改使用通配符星号区域的一个问题。我一点也不熟悉,是如何工作的,并只找到关于域的区域的东西被广泛探讨的域管理器。我不知道,我知道我在做什么。我稍微熟悉的.htaccess,但它仍然是我写的正则表达式一个很大的挑战。

I am trying to use a combination of .htaccess and PHP to create subdomains on-the-fly on my GoDaddy Hosting account. I've run into a problem of trying to modify the zone using the wildcard asterisk. I am not at all familiar with how this works and have only found the zone stuff about the domain by exploring the domain manager extensively. I'm not sure I know what I'm doing. I'm slightly more acquainted with .htaccess, although it's still a big challenge for me to write RegEx.

我已经研究将使用的.htaccess重新路由子域到一个文件夹在我的域名的根另一个教程(如sub.domain到domain/sub~~V)。这是我的code:

I've researched another tutorial that will use .htaccess to reroute a subdomain to a folder in the root of my domain (e.g. sub.domain to domain/sub). Here's my code:

#Grab the subdomain from the domain RewriteCond %{HTTP_HOST} ^([^.]+).MY-DOMAIN$ #Make sure the subdomain is not www or example RewriteCond %{1} !^(www)$ #Check if the directory actually exists before we go there RewriteCond /home/content/X/Y/Z/XYZ-MY-GODADDY-ACCT/html/%1 -d #This stops it from looping RewriteCond %{REQUEST_FILENAME} !^/home/content/X/Y/Z/XYZ-MY-GODADDY-ACCT/html/ #Finally, this is the actual rewrite RewriteRule (.*) /home/content/X/Y/Z/XYZ-MY-GODADDY-ACCT/html/%1 [L]

截至目前,我已经做了以下内容:

As of right now, I've done the following:

  • 在登录到GoDaddy的域名管理。
  • 赴工具> DNS管理器。
  • 在打开的区域文件编辑我的域。
  • 在增加了一个A(主机)记录与主机名*和指向IP地址我复制从@条目的IP地址的值,因为这应该是同我的域名...?
  • 现在,等到或任何更新,将会传播和东西的域名服务器后,我得到一个403错误,当我试图访问一个子域。
  • 有什么建议?

    推荐答案

    DNS是配置中只有1份。你需要有添加ServerAlias​​为* .mydomain为在Apache中的虚拟主机的配置,否则Apache将不必路由请求任何想法,其中* .mydomain - 这意味着的.htaccess从未有机会在所有的工作。

    DNS is only 1 part of the configuration. You need to have a ServerAlias for *.mydomain in the configuration for the virtual host in Apache, otherwise Apache will not have any idea where to route requests for *.mydomain - which means the .htaccess never has a chance to work at all.

    如果GoDaddy的提供了一种方法来手动编辑你的虚拟主机的指令,或至少通过他们的图形用户界面添加服务器别名的能力,那么它很容易做到。如果你不能找到它,你应该联系GoDaddy的信息。

    If GoDaddy provides a way to manually edit your virtual hosts' directives, or at least the ability to add server aliases through their GUI, then it's easy enough. If you can't find it, you should contact GoDaddy for information.

    更多推荐

    我可以动态创建子域(PHP,的.htaccess)与GoDaddy主机?

    本文发布于:2023-10-31 16:03:59,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1546583.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:主机   动态   htaccess   PHP   GoDaddy

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!