Codeigniter3:在新主机中移植网站只是索引方法可见并且请求超过了 10 个内部重定向的限制

问题描述 投票:0回答:0

我看了一眼类似的问题,但我认为我的问题是不同的,因为我已经成功地将我正在处理的网站移植到本地主机上。现在我需要将目前托管在共享主机中的生产网站移植到更专业的空间。两者都在 linux 操作系统下,我 PC 上的本地主机副本在 Windows 下。一旦我将所有文件夹和文件从当前共享的生产主机复制到新主机,我可以看到只有主控制器的 index 方法可以访问,而所有其他公共方法都无法访问并且“Not已找到。在此服务器上未找到请求的 URL。”返回错误。

文件夹分为两个主要组,每个组都有不同的 Codeigniter3 实现:

  • public_html
    • 终端用户
      • 缓存
      • 配置
      • 控制器
        • 前端控制器
          • 指数
          • 研究
          • 新闻
          • (其他方法)...
      • 模型
      • (等)...
    • 管理员
      • 缓存
      • 配置
      • 控制器
      • 模型
      • (等)...

其中“admin”是网站管理员完全独立的部分,只有他们知道。假设网站的域是“mywebsite.com”,环境配置为访问隐藏文件夹“endUsers”的所有页面。只需通过 URL“mywebsite.com”即可访问主页,而无需编写 endUsers 文件夹名称以及所有其他控制器和方法。例如,从主页上的表单启动研究,最终用户将看到生成的 URL“mywebsite.com/frontController/research”,而不是“mywebsite.com/endUsers/frontController/research”。对于管理员页面,情况有所不同,管理员必须明确文件夹“admin”,例如“mywebsite.com/admin/controller_name”。

工作当前生产主机和本地主机中的配置 .htaccess 文件定义如下:

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


RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 4000
   php_value memory_limit 1024M
   php_value post_max_size 256M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php71"
   php_value upload_max_filesize 1024M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 4000
   php_value memory_limit 1024M
   php_value post_max_size 256M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php71"
   php_value upload_max_filesize 1024M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

routs.php文件如下

$route['default_controller'] = 'frontController';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

我不知道新托管服务器中的哪个配置仍然是错误的(Apache 或 Codeigniter);在这三种情况下,Web 服务器都是 Apache。

编辑 20/04/2023 在 apache2.config 中我改变了

<Directory /var/www/>
   Options Indexes
   FollowSymLinks Allow
   Override None
   Require all granted
</Directory>

进入

Override All

这将我尝试访问不同于 index() 的 frontController 方法的错误更改为“500 内部服务器错误”。我不知道新托管服务器中的哪个配置仍然是错误的(Apache 或 Codeigniter);在这三种情况下,Web 服务器都是 Apache。我瞥了一眼我可以阅读的错误日志

[Thu Apr 20 13:32:29.497750 2023] [core:error] [pid 207555] [client [IP]:41410] AH00124: 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., referer: https://[IP]/index.php/frontController/productsResearch"

一开始这个更改后的主页是有效的(浏览器缓存还是真的有效?);现在不是。系统管理员工具是Webmill,不是cPanel。

apache .htaccess codeigniter url-routing webmin
© www.soinside.com 2019 - 2024. All rights reserved.