0

我有一个托管在 godaddy 上的 Zend 应用程序,其域名指向包含该应用程序的子文件夹,这在使用域名时导致 500 服务器错误。我使用的是 Linux 主机,公共文件夹的路径是 /Subfolder Name/public,这是指向域名的位置。令人困惑的是,当我导航到以下站点时:主机 IP 地址/子文件夹路径没有问题。使用域名进行导航时,错误日志中会生成以下内容:

Request exceeded the limit of 10 internal redirects due to probable configuration error.

环顾四周后,这似乎是一个 .htaccess 问题。我的公用文件夹中的 .htaccess 文件如下:

    RewriteEngine On
    # The following rule tells Apache that if the requested filename
    # exists, simply serve it.
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    # The following rewrites all other queries to index.php. The 
    # condition ensures that if you are using Apache aliases to do
    # mass virtual hosting, the base path will be prepended to 
    # allow proper resolution of the index.php file; it will work
    # in non-aliased environments as well, providing a safe, one-size 
    # fits all solution.
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
    RewriteRule ^(.*)$ - [E=BASE:%1]
    RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
4

1 回答 1

1

第一条规则应该防止内部重定向,因此路由到的最后一次重写可能index.php是错误的。尝试更改它以简化路由:

RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

到:

RewriteRule ^(.*)$ /index.php [L]

如果index.php位于另一条路径中,则只需更改/index.php,使其指向正确的位置。

于 2013-04-10T21:50:47.320 回答