Apache2 通配符子域
我有一个问题想看看是否有可能,因为我的搜索结果显示为空,或者同一个博客讲述了完全不同的内容...
基本上我已将 *.mydomain.com 的 A 记录添加到我的 IP 中...好的,简单的事情结束了。
现在我创建了一个看起来相似的 VirtualHost:
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias *.mydomain.com
DocumentRoot /home/sites/mydomain.com/htdocs
</VirtualHost>
现在,如果我希望它们全部指向 index.php 页面,上面的内容就很好了。不过我想要一个更复杂的 VirtualHost...
该链接看起来有点像这样:
http:// someusername.mydomain.com/public/repositoryname
然后,这将指向类似以下内容的内容:
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias *.mydomain.com
<Location /home/svn/{someusername}/{public}/{repositoryname}>
#Some more code in here...
</Location>
</VirtualHost>
显然,位置变量为:
{someusername} - Will be what the subdomain is
{public} - Will be the first GET parameter from the url query string
{repositoryname} - Will be the second GET paramter from the url query string
现在我知道这可能会使 Apache WildCards 达到极限,但我需要知道这是否是能否实现。
非常感谢, 肖恩
I've a question to see if it's possible as my search results are turning up empty or with the same blog telling something totally different...
Basically I've added an A Record for *.mydomain.com to my IP... ok, simple stuff over.
Now I've created a VirtualHost which looks something alike:
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias *.mydomain.com
DocumentRoot /home/sites/mydomain.com/htdocs
</VirtualHost>
Now the above is fine for if I want them all pointing to the index.php page. However I'm wanting a little more complex VirtualHost...
The link will look someting alike this:
http://someusername.mydomain.com/public/repositoryname
This would then point to something alike the following:
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias *.mydomain.com
<Location /home/svn/{someusername}/{public}/{repositoryname}>
#Some more code in here...
</Location>
</VirtualHost>
Obviously the Location variables for:
{someusername} - Will be what the subdomain is
{public} - Will be the first GET parameter from the url query string
{repositoryname} - Will be the second GET paramter from the url query string
Now I know this is possibly bending Apache WildCards to the limit, but I need to know if this is achievable or not.
Many thanks,
Shaun
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了如何通过启用 mod_perl 并编写自定义 perl 脚本来实现此目的。任何有类似问题的人肯定会考虑使用 Perl 来解决这个问题!
I found out how to achieve this by enabling mod_perl and writing a custom perl script. Anyone with a similar issue definately look into using Perl for this!