I want to specific a host of http request, can Greasemonkey help me to do this job?
I have search "DNS" and "host" in userscripts.org, but I can'开发者_StackOverflowt found my answer.
Sometimes I want to do some test in my development enviroment, for example, 192.168.22.11 testfunc.myDomain.com
But I don't want to change the C:\Windows\System32\drivers\etc\hosts file all the time and restart my browser.
The question is not clear.
You want to locally reroute myDomain.com
to 192.168.22.11?
Greasemonkey can automatically reload pages, changing the server or IP, but I don't recommend that. It would be a messy endeavor -- especially handling all the href
and src
attributes, etc.
If I read the question correctly, the Redirector add-on would be a better fit.
~~~
HOWEVER, the proper way to do this is to structure your site and your apps so that everything uses relative addresses, AMAP. Use a single bit of code to detect the running server, once per request (or once per app init), and to set a <base>
element and/or an appropriate global variable.
The point is that our code runs without any changes whether it's dropped on ProductionServer.com, or TestServer.com, or 192.168.22.11
. So, there is no need for redirects, or even slight modifications between test code and production code.
精彩评论