【问题标题】:.htaccess - mod_dir with RewriteRule Proxy.htaccess - 带有 RewriteRule 代理的 mod_dir
【发布时间】:2012-07-04 08:54:43
【问题描述】:

我遇到了一个不寻常的问题。我有一系列指向我托管网站的网站,例如:

http://sub.mydomain.com/help/

所有这些其他网站都使用这个 .htaccess 文件

Options +FollowSymLinks -Indexes
RewriteEngine on

RewriteRule ^(.*)$ http://sub.mydomain.com/$1 [P,E=Proxy-Host:sub.mydomain.com]

它在大多数情况下都很好用。让我们将这些其他域之一称为“sub.otherdomain.com”。

如果我转到http://sub.otherdomain.com/help/,它可以正常工作。

如果我转到http://sub.otherdomain.com/help,它将被重定向到http://sub.mydomain.com/help/

原因是mod_dir将/重定向到主域。

我希望它将 / 重定向到代理域。

有什么想法吗?

【问题讨论】:

  • 你可以在sub.otherdomain.com 配置中尝试DirectorySlash Off
  • 不起作用 - sub.mydomain.com(标准 wordpress)上的 htaccess 是导致问题的原因。如果你把DirectorySlash Off 放在那里,它根本不起作用。

标签: .htaccess mod-rewrite mod-proxy


【解决方案1】:

您需要设置ProxyPassReverse。这不能在 htaccess 中完成。您需要在<VirtualHost> 部分添加此内容。

【讨论】:

  • VirtualHost 是什么? httpd.conf?你能给我举个例子吗?
  • 我的意思是在 httpd.conf 中,但将其放入定义 otherdomain 的虚拟主机中可能是明智的。我的地址是/etc/apache2/site-enabled/<name of host or something>
猜你喜欢
  • 1970-01-01
  • 2015-10-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-21
  • 1970-01-01
  • 1970-01-01
  • 2013-09-08
相关资源
最近更新 更多