在.htaccess中没有重定向的代理子域

时间:2013-03-04 16:22:56

标签: apache .htaccess proxy subdomain

需要将发送到子域auto.domain.int的请求重定向到www.domain.int/doc/sample-rates。它是Zend应用程序,因此使用MVC。我的.htaccess conf中有以下内容:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^auto\.domain\.int$
RewriteRule ^.*$ /doc/sample-rates [PT,L]

问题是,当我将一个真实文件的名称放在文件系统上作为RewriteRule替换时,让我们说'script.php',这一切都运行良好。 script.php文件的内容在auto.domain.int主机名下提供。

另一方面,当我将MVC路由作为RewriteRule替换时,我从apache获取了500个错误,用于'/ doc / sample-rates'路径,400错误用于'http://www.domain.int/doc/sample-rates'路径和apache中的几行日志:

127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d75058/initial] (3) [perdir /var/www/domain/base/www.domain.com/htdocs/] strip per-dir prefix: /var/www/domain/base/www.domain.com/htdocs/ -> 
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d75058/initial] (3) [perdir /var/www/domain/base/www.domain.com/htdocs/] applying pattern '^.*$' to uri ''
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d75058/initial] (2) [perdir /var/www/domain/base/www.domain.com/htdocs/] rewrite '' -> '/doc/sample-rates'
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d75058/initial] (2) [perdir /var/www/domain/base/www.domain.com/htdocs/] forcing '/doc/sample-rates' to get passed through to next API URI-to-filename handler
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d75058/initial] (1) [perdir /var/www/domain/base/www.domain.com/htdocs/] internal redirect with /doc/sample-rates [INTERNAL REDIRECT]
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d67018/initial/redir#1] (3) [perdir /var/www/domain/base/www.domain.com/htdocs/] add path info postfix: /var/www/domain/base/www.domain.com/htdocs/doc -> /var/www/domain/base/www.domain.com/htdocs/doc/sample-rates
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d67018/initial/redir#1] (3) [perdir /var/www/domain/base/www.domain.com/htdocs/] strip per-dir prefix: /var/www/domain/base/www.domain.com/htdocs/doc/sample-rates -> doc/sample-rates
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d67018/initial/redir#1] (3) [perdir /var/www/domain/base/www.domain.com/htdocs/] applying pattern '^.*$' to uri 'doc/sample-rates'
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d67018/initial/redir#1] (2) [perdir /var/www/domain/base/www.domain.com/htdocs/] rewrite 'doc/sample-rates' -> '/doc/sample-rates'
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d67018/initial/redir#1] (2) [perdir /var/www/domain/base/www.domain.com/htdocs/] forcing '/doc/sample-rates' to get passed through to next API URI-to-filename handler
127.0.0.1 - - [04/Mar/2013:10:50:19 --0500] [auto.domain.int/sid#b73cd9d8][rid#b6d67018/initial/redir#1] (1) [perdir /var/www/domain/base/www.domain.com/htdocs/] internal redirect with /doc/sample-rates [INTERNAL REDIRECT]


更新:auto.domain.int是使用ServerAlias的“main”www.domain.int的别名。



谢谢,
尤金

1 个答案:

答案 0 :(得分:1)

您必须添加额外的RewriteCond以防止无休止的重写

RewriteCond %{HTTP_HOST} ^auto\.domain\.int$
RewriteCond %{REQUEST_URI} !^/doc/sample-rates$
RewriteRule ^.*$ /doc/sample-rates [PT,L]