将文件夹重定向到其他服务器

将文件夹重定向到其他服务器

问题描述:

I know you can redirect subdomains to a different server, but can you do the same with folders?

Say I have example.com. I can redirect mysubdomain.example.com to a different server, but can I redirect example.com/mysubdomain to a different server? I'd like to host a rails app in that folder on a site that runs php while still maintaining good search engines ratings (by not creating a sub domain which in my experience in recognized as a different site).

Any help?

Thanks!

我知道您可以将子域重定向到其他服务器,但是您可以对文件夹执行相同操作吗? p>

说我有example.com。 我可以将mysubdomain.example.com重定向到其他服务器,但是我可以将example.com/mysubdomain重定向到其他服务器吗? 我想在运行php的网站上的该文件夹中托管一个rails应用程序,同时仍然保持良好的搜索引擎评级(通过不创建一个根据我的经验被认可为不同网站的子域名。) p>

任何帮助? p>

谢谢! p> div>

As brock Batsell suggested, a solution can be proxying the requests. you'll usually find this behavior in web apps that use long polling services, like chats, and need to proxy out those services to a second web server to reduce the load on the main one (usually, apache + lighhtpd)

Here is the basic usage (assuming youre using apache, and the other web-server is listening on the 81 port):

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

ProxyRequests Off
ProxyPreserveHost On
proxypass /folder-to-proxy http://localhost:81/folder
proxypassReverse /folder-to-proxy http://localhost:81/folder

<Proxy http://localhost:81/>
    Order Allow,Deny
    Allow from all
</Proxy>

Just replace the localhost and port number with your second server host and port.

Please note that even if you dont need to proxy the ftp traffic, in apache the proxy_ftp_module must be enabled as well.

You can only do this via a proxy, which can forward all requests to the /mysubdomain folder to a particular IP and port, get the response, then return the response to the user transparently.

Pretty much any mainstream web server will have a module to do this if you have control over its configuration file. (Apache has mod_proxy, nginx has HTTP Proxy, lighttpd has its own mod_proxy.)