After installing CI4 with Myth/Auth on a shared server using cPanel and Softaculous, I get a 404 when I enter a username/password and press Login.
To make it as simple as possible, my test application just has:
- CI4 (4.1.5)
- Myth/Auth (1.0.1).
Things that work:
https://mindstg.xxxxxxx.xxx.au/
https://mindstg.xxxxxxx.xxx.au/public/login
What doesn’t work:
Pressing the Login button on
https://mindstg.xxxxxxx.xxx.au/public/login
A thing that makes it work:
Change (hack) the <form> tag in Myth/Auth Login form (using the HTML editor in the browser)
- from <form action="/login" method="post">
- to “<form action="/public/login" method="post">”
Pressing Login then redisplays the Login page with validation errors:
Environment:
Folder structure:
public/index.php (unchanged from default)
PHP Code:
<?php
// Path to the front controller (this file)
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
/*
*---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION
*---------------------------------------------------------------
* This process sets up the path constants, loads and registers
* our autoloader, along with Composer's, loads our constants
* and fires up an environment-specific bootstrapping.
*/
// Ensure the current directory is pointing to the front controller's directory
chdir(__DIR__);
// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure.
$pathsConfig = FCPATH . '../app/Config/Paths.php';
// ^^^ Change this if you move your application folder
require realpath($pathsConfig) ?: $pathsConfig;
$paths = new Config\Paths();
// Location of the framework bootstrap file.
$bootstrap = rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
$app = require realpath($bootstrap) ?: $bootstrap;
/*
*---------------------------------------------------------------
* LAUNCH THE APPLICATION
*---------------------------------------------------------------
* Now that everything is setup, it's time to actually fire
* up the engines and make this app do its thang.
*/
$app->run();
.htaccess (as created by the Softaculous CodeIgniter installer)
Code:
# To prevent access to .env and other files
<Files .*>
# Apache 2.2
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
</Files>
<IfModule mod_alias.c>
RedirectMatch 301 ^/$ https://mindstg.xxxxxxx.xxx.au/public
</IfModule>
.env (as created by the Softaculous Codeigniter installer)
Code:
#--------------------------------------------------------------------
# ENVIRONMENT
#--------------------------------------------------------------------
CI_ENVIRONMENT = development
#--------------------------------------------------------------------
# APP
#--------------------------------------------------------------------
app.baseURL = 'https://mindstg.xxxxxxx.xxx.au/public/'
#--------------------------------------------------------------------
# DATABASE
#--------------------------------------------------------------------
database.default.hostname = localhost
database.default.database = xxxxxxxx_mindstg
database.default.username = xxxxxxxx_mindstg
database.default.password = xxxxxxxxxxxxxxxx
database.default.DBDriver = MySQLi
database.default.DBPrefix =
app/Config/Routes.php (unchanged from standard)
PHP Code:
<?php
namespace Config;
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
require SYSTEMPATH . 'Config/Routes.php';
}
/*
* --------------------------------------------------------------------
* Router Setup
* --------------------------------------------------------------------
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);
/*
* --------------------------------------------------------------------
* Route Definitions
* --------------------------------------------------------------------
*/
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');
/*
* --------------------------------------------------------------------
* Additional Routing
* --------------------------------------------------------------------
*
* There will often be times that you need additional routing and you
* need it to be able to override any defaults in this file. Environment
* based routes is one such time. require() additional route files here
* to make that happen.
*
* You will have access to the $routes object within that file without
* needing to reload it.
*/
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
vendor/myth/auth/src/Config/Routes.php (unchanged from standard)
PHP Code:
<?php
/*
* Myth:Auth routes file.
*/
$routes->group('', ['namespace' => 'Myth\Auth\Controllers'], function ($routes) {
// Login/out
$routes->get('login', 'AuthController::login', ['as' => 'login']);
$routes->post('login', 'AuthController::attemptLogin');
$routes->get('logout', 'AuthController::logout');
// Registration
$routes->get('register', 'AuthController::register', ['as' => 'register']);
$routes->post('register', 'AuthController::attemptRegister');
// Activation
$routes->get('activate-account', 'AuthController::activateAccount', ['as' => 'activate-account']);
$routes->get('resend-activate-account', 'AuthController::resendActivateAccount', ['as' => 'resend-activate-account']);
// Forgot/Resets
$routes->get('forgot', 'AuthController::forgotPassword', ['as' => 'forgot']);
$routes->post('forgot', 'AuthController::attemptForgot');
$routes->get('reset-password', 'AuthController::resetPassword', ['as' => 'reset-password']);
$routes->post('reset-password', 'AuthController::attemptReset');
});
What I need:- for the Login button on the Myth/Auth Home page to work
For bonus points (ie: more profuse thanks

):
Thanks!
Malcolm