I gave a glance at similar questions, but I think my problem is different since I have already ported the website I am working on to a local host successfully. Now I need to port the production website, currently hosted in a shared hosting, to a more professional space. Both are under linux OS, the localhost replica on my PC is under Windows. Once I have copied all the folders and files from the currently shared production hosting to the new hosting, what I can see is that just the index method of the main controller is reachable, whereas all the other public methods are not reachable and a "Not Found. The requested URL was not found on this server." error is returned.
The folders are organized into two main groups each with a distinct Codeigniter3 implementation:
- public_html
- endUsers
- cache
- config
- controllers
- frontController
- index
- research
- news
- (other methods) ...
- frontController
- models
- (etc) ...
- admin
- cache
- config
- controllers
- models
- (etc) ...
- endUsers
where "admin" is the completely independent section for the website administrators and it is known just by them. Provided that the domain of the website is "mywebsite.com", the environment is configured to reach all the pages hiding the folder "endUsers". The homepage is reachable just by the URL "mywebsite.com" without writing the endUsers folder name as well as all the other controllers and methods. For instance, launching a research from a form on the home page the end user will see the resulting URL "mywebsite.com/frontController/research" and not "mywebsite.com/endUsers/frontController/research". For the administrator pages it goes differently, the admins have to explicit the folder "admin", something like "mywebsite.com/admin/controller_name".
The configuration .htaccess file in both the working current production hosting and the localhost is defined as follows:
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
The routs.php file is as follows
$route['default_controller'] = 'frontController';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I don't know which configuration in the new hosting server could still be wrong (Apache or Codeigniter); in all three cases, the web server is Apache.
EDIT 20/04/2023 In apache2.config I changed
<Directory /var/www/>
Options Indexes
FollowSymLinks Allow
Override None
Require all granted
</Directory>
into
Override All
This changed the error I get trying to access frontController methods different than index() into "500 Internal Server Error". I don't know which configuration in the new hosting server could still be wrong (Apache or Codeigniter); in all three cases, the web server is Apache. I gave a glance at the error log where I can read
[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"
At first the home page after this change was working (browser cache or really working?); right now it isn't. The system administrator tool is Webmill, not cPanel.