mod_rewrite到达LimitInternalRecursion

时间:2012-05-18 12:36:22

标签: mod-rewrite apache2

我有一个VServer,我在/ var / www /中有一些管理员应用程序, / var / customers / webs / web001 /.

中的其他常见内容

我想为所有不存在的文件和目录进行重定向

            /var/www/ -> /var/customers/webs/web001/

这样我就可以使用域名为root用户和web001用户。

我不确定实现这一目标的最佳方法是什么。 我尝试使用mod_rewrite,但是内部重定向达到了递归限制。

我做错了什么?

的.htaccess

            # allow psydo-location (not existing folder)
            Options +FollowSymLinks

            # Turn on URL rewriting engine
            RewriteEngine On

            # Folder of this htaccess-file in not root-folder
            RewriteBase /var/www/

            # Disable rewriting for existing files or directories
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !^/var/customers/webs/web001/

            # redirect all other requests to index.php
            rewriteRule ^.*$ /var/customers/webs/web001/index.php [DPI,L]

的apache2 / error.log中

            Request exceeded the limit of 10 internal redirects 
            due to probable configuration error. 
            Use 'LimitInternalRecursion' to increase the limit if necessary. 
            Use 'LogLevel debug' to get a backtrace.
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /var/customers/webs/web001/index.php
            redirected from r->uri = /index.php

rewrite.log

            (3) [perdir /var/www/] strip per-dir prefix: /var/www/index.php -> index.php
            (3) [perdir /var/www/] applying pattern '^.*$' to uri 'index.php'
            (4) [perdir /var/www/] RewriteCond: input='/var/www/index.php' pattern='!-f' => matched
            (4) [perdir /var/www/] RewriteCond: input='/var/www/index.php' pattern='!-d' => matched
            (4) [perdir /var/www/] RewriteCond: input='/var/www/index.php' pattern='!^/var/customers/webs/web001/' => matched
            (2) [perdir /var/www/] rewrite 'index.php' -> '/var/customers/webs/web001/index.php'
            (2) [perdir /var/www/] trying to replace prefix /var/www/ with /var/www/
            (1) [perdir /var/www/] internal redirect with /var/customers/webs/web001/index.php [INTERNAL REDIRECT]
            (3) [perdir /var/www/] add path info postfix: /var/www/var -> /var/www/var/customers/webs/web001/index.php

1 个答案:

答案 0 :(得分:1)

确定。我找到了解决方案。 它不在.htaccess中,而是在httpd.conf中。 通过DocumentRoot的适当设置,几乎所有请求都将从/ var / customers / webs / web001 /开始提供, 除了那些将被Alias-Directives排除在外的人。

/etc/apache2/httpd.conf看起来像这样:

            #NameVirtualHost SERVER_IP:PORT
            <VirtualHost SERVER_IP:PORT>
                ServerName SERVER_IP
                ServerAlias DOMAIN.TLD

                # instead of DocumentRoot "/var/www/"
                DocumentRoot "/var/customers/webs/web001/"

                # add Aliases for each Application in the /var/www
                Alias /URL_SUB_PATH_APP_1 "/var/www/URL_SUB_PATH_APP_1"
                Alias /URL_SUB_PATH_APP_2 "/var/www/URL_SUB_PATH_APP_2"
            </VirtualHost>

            Include /etc/apache2/vhosts.conf

就像Gerben所说,.htaccess文件对此目的没有帮助。

相关问题