我已经开始运行apache web服务器了。一个在端口80上,另一个在端口8077上。
如果可能的话,我想尝试通过端口80版本重定向所有流量。
我理想的是能够去http://translate.example.com 并且流量将定向到http://www.example.com:8077
我已经在主端口80服务器上进行了很多mod_rewrite,但我不确定哪些服务器需要配置,或者两者都需要配置。
我想确保translate.example.com/img(或任何其他子目录)实际指向8087 / images目录。
更新
我现在得到以下内容:
RewriteCond %{HTTP_HOST} example[NC]
RewriteCond %{REQUEST_URI} ^/glot$ [NC]
RewriteRule ^(.*)$ http://www.example.com:8077/$1 [P]
ProxyPassReverse / http://www.example.com/
我正在查看其他服务器的新页面,但我发现所有资源都没有找到像图片,css等
执行视图源已安装产品中的所有资源都使用前导斜杠设置
例如
/img/glotpress-logo.png
所以我不确定如何加载资源。 请注意,如果最初的起点是www.example.com/glot而不是原始问题中的glot.example.com,我会非常高兴
答案 0 :(得分:1)
您可以将资源重新映射到另一台服务器,但将其他服务器放在非默认端口上可能会阻止某些访问者查看它们,因为它们可能阻止(防火墙)访问该端口。如果您不担心端口阻塞,可以使用mod_rewrite Remapping Resources.方法。
RewriteEngine On
RewriteRule ^/images/(.+) http://www.example.com:8077/images/$1 [R,L]
如果您想确保每个人都能够查看外部资源,您需要使用代理,其中apache将透明地将访问者连接隧道传送到example.com:8077。您可以在apache网站上阅读有关mod_rewrite for Proxying的更多信息。
RewriteEngine on
RewriteBase /images/
RewriteRule ^images/(.*)$ http://example.com:8077/images/$1 [P]
ProxyPassReverse /images/ http://example.com/images/
<强>更新强>
您是否尝试删除
RewriteCond %{HTTP_HOST} example[NC]
这一行基本上告诉它只会在HTTP_POST是example.com时处理,如果它来自www.example.com,则此规则不适用。我希望“例子[NC]”是一个错字。
最后它可能看起来像
RewriteRule ^/glot/(.*)$ http://www.example.com:8077/glot/$1 [P]
ProxyPassReverse /glot/ http://www.example.com:8077/glot/
答案 1 :(得分:0)
您需要在端口80服务器上进行配置,以使其充当8077服务器的代理。
Apache文档在这里:http://httpd.apache.org/docs/trunk/rewrite/proxy.html