apache - 将 CodeIgniter 安装移动到子域会导致 500 内部服务器错误

标签 apache .htaccess codeigniter subdomain

在我的新子域上,主页工作正常,但其他所有内容都会引发 500 内部服务器错误。我确信这是一个 .htaccess 问题。我在 GiftFlow.org 上有一个基于 CodeIgniter 的网络应用程序,并且工作正常。

网络根目录/var/www/vhosts/giftflow.org/httpdocs

从我的托管控制面板中,我创建了一个子域favorece.giftflow.org,并将所有内容克隆到其中。

网络根目录/var/www/vhosts/favorece.giftflow.org/httpdocs

当我从浏览器调用 favorece.giftflow.org 时,索引页面显示正常,包括 CSS,但当我尝试导航到任何其他页面时,我收到 500 内部服务器错误。我的 Apache 错误日志显示:

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.

这是我在 CodeIgniter 的 application/config/config.php 中的 base_url

$config['base_url'] = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'.$_SERVER['HTTP_HOST'].str_replace('//','/',dirname($_SERVER['SCRIPT_NAME']).'/');

我的 .htaccess 文件位于 favorece.giftflow 的 webroot 中:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|user_guide|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /giftflow/index.php/$1 [L]

最佳答案

您不断重定向到 /giftflow/index.php。 RewriteBase 以及 RewriteRule 的附加标志可能会有所帮助。尝试:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]

此外,CI 通常会自动检测 base_url,因此将其留空很可能是安全的。您在 config.php 中定义的逻辑最好也放在主 index.php 文件中。

关于apache - 将 CodeIgniter 安装移动到子域会导致 500 内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9624190/

相关文章:

php - Codeigniter -> 附上电子邮件

javascript - 单击忘记按钮表单应该使用 jquery 进行验证

php - PHP/MYSQL对更新字段的操作

php - 第 177 行出现 fatal error : Call to undefined function mb_detect_encoding() in C:\apache\htdocs\phpmyadmin\libraries\php-gettext\gettext. inc

php - 更改两个域的根目录

apache - 集成 Solr 和 Mahout

.htaccess 子域的通配符 SSL

php - slim 的 PHP 路由不起作用

linux - .htaccess mod_rewrite 删除 .php 扩展名,但保留 URL 路径

java - 使用 apache camel 创建休息服务时出错