开发者

1 domain.. 2 server and 2 applications

i have a site like twitter.com on server one and on server two i have forum, which path is like domain.com/forum

on server one i wanted to implement wild card dns and put main domain on it. but on server two i wanted to keep forum separate, i cant give sub-domain f开发者_JS百科orum.domain.com, because all its links are already put in search engines and link back to domain.com/forum.

so i was wondering, how can i put domain and wild card dns on server one and still able to give path on server 2 for domain.com/forum (as sub-folder).

any ideas?

do you think htaccess can do that job? if yes, then how?


You could use htaccess and mod_rewrite so domain.com/forum actually displays pages from forum.domain.com.

Maybe something like this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule domain.com/forum/(.+) forum.domain.com/$1


Easy - use a proxy! If you like apache you will love apache mod_proxy for your purpose.

<VirtualHost *:80>
    ServerName  maindomain.com
    ServerAlias *.maindomain.com

    # insert document root and general settings for this domain here
    # ...

    ProxyPass /forum http://forumdomain.com
    ProxyPassReverse /forum http://forumdomain.com
    ProxyPassReverseCookieDomain forumdomain.com maindomain.com
</VirtualHost>

This configuration makes apache do a HTTP-request to your internal domain (forumdomain.com) without notifiying the users browser of the internal location. Your Forum will be accessable at http://*.yourdomain.com/forum. Cookies and headers the forum sents will get rewritten accordingly and Search-engines will not take notice of your backend-server.

You can read more about it at http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

Should you need to rewrite reference sin your html (href, src ...) you might google on "mod_proxy_html".

A solution like this could of course be build with other intelligent proxyservers like squid as well. You can use it to map any content from "backend servers" to your public domain. Make sure routing is OK or set up a host-entry for your internal domain (forumdomain) with a internet ip-addresse 192.168 ...

Enjoy your site and give feedback how worked out :)

p.s.: a "RewriteRule" directive can potentially do the same thing for you but the rdirect will be visible (and executed) by the client unless you specify the "P", foricng it to do an internal proxy request. If available I would prefer the mod_proxy though as it is more versatile and allows for more configuration.


If you use a proxy on server 1 pointing to server2, you will increase the load on server 1, since all traffic will be routed through it. Besides, if server 1 goes down, nobody will be able to reach server 2 either. Of course it is possible though, but these things are to be considered.

I would suggest setting up a supdomain for server 2 anyway, like forum.domain.com, and on server 1 you set up a 301 redirect from domain.com/forum to forum.domain.com using mod_rewrite from htaccess. Using that technique, you can even redirect calls to specific links to their corresponding page on server 2. Search engines will follow the 301 and they will eventually update the index.


You can use a 301 redirect to make sure the search engine update their index with your new urls like so:

RewriteRule domain.com/forum/(.*) http://forum.domain.com/$1 [R=301,L]


If you've got two servers you don't really have much choice but to use a redirect (ideally a 301 Permanent redirect) to move users from domain.com/forum to forum.domain.com.

The only other way to do it would be to put a reverse proxy in front of those two servers, which reads the URL and internally directs the query to the right server, but that's then an extra piece of hardware.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜