我想使用的.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:
有什么建议?
推荐答案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主机?
发布评论