在本地主机(OS X 10.5)上设置通配符域? [英] Setting up wildcard domains on local host (OS X 10.5)?

查看:102
本文介绍了在本地主机(OS X 10.5)上设置通配符域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用户可以注册并拥有自己的博客的意义上,我开始开发一个基本上充当WordPress MU的网站.我将在Rails中对此进行编码,但是我希望能够利用通配符子域,因此我可以使用诸如blog.example.com之类的格式.我已经进行了一些搜索,但是找不到任何好的资源.

I am starting to develop a site which basically acts as WordPress MU, in the sense that a user can signup and have their own blog. I will be coding this in Rails, however I am hoping to be able to utilize wildcard subdomains, so I can use the format such as blog.example.com. I've done some searching but I can't find any good resources.

由于我使用的是Rails,所以我不确定该放在哪里,因为我使用的是Mongrel,而不是Apache.我可以通过在服务器上进行远程开发来绕过本地计算机上的操作,但是我只想保留此方法.

Since I am using Rails, I'm not sure where to put this, as I am using Mongrel, and not Apache. I can bypass doing this on my local machine by developing remotely on my server, however I would only like to keep this as a last resort.

如果需要,我可以提供有关我的开发环境的更多详细信息,但这是基础知识:

I can give more details about my development environment if needed, but here are the basics:

  • Mac OS X Leopard 10.5.6
  • Ruby 1.8.7
  • 导轨2.3.2

推荐答案

严格来说,不可能在hosts文件中执行此操作(至少在OS X上如此).通过将Firefox配置为使用代理自动配置脚本,可以模拟Firefox的行为.

Strictly speaking, it's not possible to do that in the hosts file (at least on OS X). It's possible to simulate the behavior with Firefox by configuring it to use a proxy autoconfigure script.

使用以下javascript创建文件(我使用〜/.proxy.pac)

Create a file with the following javascript (I use ~/.proxy.pac)

function FindProxyForURL(url, host) {
  if (shExpMatch(host,"*.<YOUR_DOMAIN>")) {
    //alert("proxy local")
    return "PROXY localhost";
  }
//alert("proxy direct")
return "DIRECT";
}

然后在Firefox中>首选项>高级>网络>设置...>自动代理配置URL:

Then in Firefox > Preferences > Advanced > Network > Settings... > Automatic Proxy Configuration URL:

file:///Users/USERNAME/.proxy.pac

从未在Safari中尝试过它,但它也支持PAC文件,因此也许可以使用...

Never tried it in Safari, but it supports PAC files also, so perhaps it works...

我知道的唯一其他选择是在PC上设置完整的DNS服务器...

The only other alternative I know is to set up a full blown DNS server on your PC...

这篇关于在本地主机(OS X 10.5)上设置通配符域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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