Welcome Guest, Not a member yet? Register   Sign In
Installing as a subdomain using cPanel and Softaculous
#1
Smile 

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:
[Image: view?usp=sharing]

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 Smile ): Thanks!
Malcolm
Reply
#2

Ok. After a LOT of trial and error, I've found a combination that does what I want.

I'm posting my solution here, not because I think that it's a wonderful solution (I don't really understand how/why it works), but in the hope that it might be useful to someone else and/or someone can explain it to me.

Cheers
Malcolm

.htaccess (replaced RedirectMatch with RewriteCond/RewriteRule):
Code:
<IfModule mod_alias.c>
#RedirectMatch 301 ^/$ https://mindstg.xxxxxxx.xxx.au/public
RewriteCond %{HTTP_HOST} ^mindstg.xxxxxxx.xxx.au
RewriteRule (.*) https://mindstg.xxxxxxx.xxx.au/public/$1 [R=301,P]
</IfModule>

.env (removed '/public' from app.baseURL):
Code:
#--------------------------------------------------------------------
# APP
#--------------------------------------------------------------------

#app.baseURL = 'https://mindstg.xxxxxxx.xxx.au/public/'
app.baseURL = 'https://mindstg.xxxxxxx.xxx.au/'
Reply
#3

Awesome, I'm having this problem. thank you
Reply




Theme © iAndrew 2016 - Forum software by © MyBB