1 个域.. 2 个服务器和 2 个应用程序

发布于 2024-09-02 20:10:30 字数 324 浏览 2 评论 0原文

我在服务器一上有一个像 twitter.com 这样的网站,在服务器二上我有论坛,其路径就像

服务器一上的domain.com/forum 我想实现通配符 dns 并将主域放在上面。但在服务器二上,我想将论坛分开,我无法提供子域forum.domain.com,因为它的所有链接都已放入搜索引擎中并链接回domain.com/forum。

所以我想知道,如何将域和通配符 dns 放在服务器 1 上,并且仍然能够在服务器 2 上为domain.com/forum(作为子文件夹)提供路径。

有什么想法吗?

你认为 htaccess 可以完成这项工作吗?如果是,那么如何?

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 forum.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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

爱情眠于流年 2024-09-09 20:10:30

您可以使用 htaccess 和 mod_rewrite,以便domain.com/forum 实际上显示来自forum.domain.com 的页面。

也许是这样的:

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

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
℉服软 2024-09-09 20:10:30

简单 - 使用代理!如果您喜欢 apache,您一定会喜欢 apache mod_proxy 来实现您的目的。

<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>

此配置使 apache 向您的内部域 (forumdomain.com) 发出 HTTP 请求,而不通知用户浏览器内部位置。您的论坛可通过 http://*.yourdomain.com/forum 访问。论坛发送的 Cookie 和标头将相应地被重写,搜索引擎不会注意到您的后端服务器。

您可以在 http://httpd.apache.org/docs 阅读更多相关信息/2.2/mod/mod_proxy.html

如果您需要重写 html 中的引用(href、src ...),您可以在 google 上搜索“mod_proxy_html”。

当然,也可以使用其他智能代理服务器(例如鱿鱼)来构建这样的解决方案。您可以使用它将任何内容从“后端服务器”映射到您的公共域。
确保路由正常或使用互联网 ip 地址 192.168 为您的内部域(forumdomain)设置主机条目...

享受您的网站并提供反馈如何解决:)

ps:“RewriteRule”指令可能会做对你来说是一样的,但是 rdirect 将对客户端可见(并执行),除非你指定“P”,迫使它执行内部代理请求。如果可用的话,我更喜欢 mod_proxy,因为它更通用并且允许更多配置。

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.

皓月长歌 2024-09-09 20:10:30

如果您在服务器 1 上使用指向服务器 2 的代理,则会增加服务器 1 上的负载,因为所有流量都将通过它进行路由。此外,如果服务器 1 出现故障,也没有人能够访问服务器 2。当然这是可能的,但是这些事情都是要考虑的。

我建议无论如何为服务器 2 设置一个超级域名,例如 forum.domain.com,并在服务器 1 上使用 htaccess 的 mod_rewrite 设置从 domain.com/forum 到 forum.domain.com 的 301 重定向。使用该技术,您甚至可以将对特定链接的调用重定向到服务器 2 上的相应页面。搜索引擎将遵循 301,并最终更新索引。

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.

静赏你的温柔 2024-09-09 20:10:30

您可以使用 301 重定向来确保搜索引擎使用您的新网址更新其索引,如下所示:

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

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]
南风起 2024-09-09 20:10:30

如果您有两台服务器,那么您实际上没有太多选择,只能使用重定向(最好是 301 永久重定向)将用户从 domain.com/forum 移动到 forum.domain .com

唯一的其他方法是在这两台服务器前面放置一个反向代理,它读取 URL 并在内部将查询定向到正确的服务器,但这就是一个额外的硬件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文