Welcome Guest, Not a member yet? Register   Sign In
ci 4 not found controller in linux
#1

(This post was last modified: 05-14-2020, 06:20 AM by gra.)

I made a project with codeigniter 4.0.0 rc 3
On windows it works.
On Linux debian 10 not run.

in my .htaccess they have changed


Code:
RewriteRule ^(.*)$ index.php/$1 [L]
to
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
in Config / app

Code:
public $baseURL = 'http://my_domain.loc/';
public $indexPage = '';
public $uriProtocol = 'PATH_INFO';


I'm using php 7.3
I have enabled rewrite_module in Apache 2.
sudo a2enmod rewrite
After enabling mod_rewrite, I restarted the server

with the php function apache_get_modules () I print the list of modules. [27] => mod_rewrite.

in the browser http: //my_domain.loc/index.php default is it works.
click the buttons call MY_Controller
in my browser http: //my_domain.loc/MY_Controller is not working

Message:
NOT FOUND
The requested URL was not found on this server.

This only in Linux.

my conf host Apache 2

Code:
<VirtualHost *:80>
    ServerAdmin admin@my_domain.loc
    ServerName my_domain.loc
    ServerAlias www.my_domain.loc
    DocumentRoot /var/www/my_domain.loc/html/my_domain_folder/public
    ErrorLog ${APACHE_LOG_DIR}/my_domain.loc.error.log
    CustomLog ${APACHE_LOG_DIR}/my_domain.loc.access.log combined
</VirtualHost>



my .htaccess in the public folder




PHP Code:
# Disable directory browsing
Options All -Indexes

# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
# RewriteBase /

# Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$[L,R=301]

# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond 
%{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule http://%1%{REQUEST_URI} [R=301,L]

# Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ index.php?/$[L,QSA]

# Ensure Authorization header is passed along
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</
IfModule>

<
IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    ErrorDocument 404 index.php
</IfModule>

# Disable server signature start
    ServerSignature Off
# Disable server signature end 


my .htaccess project folder




PHP Code:
# Disabilita la navigazione nella directory 
Opzioni All -Indexes 

# --------------- -------------------------------------------------- ----- 
# Riscrivi il motore
# --------------------- -------------------------------------------------

# L'attivazione del motore di riscrittura è necessaria per le seguenti regole e funzionalità. 
# FollowSymLink deve essere abilitato affinché funzioni. 
<IfModule mod_rewrite.c>
 Opzioni SeguiSymlink 
 RewriteEngine On 

 
# Se hai installato CodeIgniter in una sottocartella, dovrai
 # cambiare la seguente riga in modo che corrisponda alla sottocartella di cui hai bisogno. 
 # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
 # RewriteBase / 

 # Reindirizza le barre finali ... 
 RewriteRule ^ (. *) / $ / $ [L301]

 # Riscrivi "www.example.com -> example.com "
 RewriteCond% {HTTPS}! = on [/ color
 RewriteCond% {HTTP_HOST} ^ www \. (. +) $ [NC]
 RewriteRule http//% 1% {REQUEST_URI} [R = 301, L] 

 # Verifica se l'utente sta tentando di accedere a un file valido,
 # come un'immagine o un documento CSS, se questo non è vero, invia il 
 # richiesta al front controller, index.php 
 RewriteCond% {REQUEST_FILENAME}! -f
 RewriteCond
% { REQUEST_FILENAME}! -D
 RewriteRule 
^ (. *) $ Index.php? / $ [LQSA]
 #inserito per xdebug [/ color ] 
 RewriteCond% {HTTP_COOKIE}! XDEBUG_SESSION [NC]
 RewriteRule ^ (. *) $ $ 1XDEBUG_SESSION_START mod_rewrite [QSAL]
 # Assicurati che l'intestazione dell'autorizzazione sia passata lungo 
 RewriteCond% {HTTPAuthorization}.
 RewriteRule. * - [HTTP_AUTHORIZATION: % {HTTPAutorizzazione}]
 </IfModule> 

 
<IfModuleMod_rewrite.c>
 # If non abbiamo installato mod_rewrite, tutti i 404 
 # possono essere inviati a index.php e tutto funziona normalmente. 
 ErrorDocument 404 index.php
 
</IfModule>

 # Disabilita avvio firma server
 ServerSignature Off
 
# Disabilita la fine della firma del server 




my index.php in pubblic folder



PHP Code:
<?php

// Valid PHP Version?
$minPHPVersion '7.2';
if (
phpversion() < $minPHPVersion)
{
die(
"Your PHP version must be {$minPHPVersion} or higher to run CodeIgniter. Current version: " phpversion());
}
unset(
$minPHPVersion);

// Path to the front controller (this file)
define('FCPATH'__DIR__ DIRECTORY_SEPARATOR);

// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath FCPATH '../app/Config/Paths.php';
// ^^^ Change this if you move your application folder

/*
*---------------------------------------------------------------
* 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
require $pathsPath;
$paths = new Config\Paths();

// Location of the framework bootstrap file.
$app = require rtrim($paths->systemDirectory'/ ') . '/bootstrap.php';

/*
*---------------------------------------------------------------
* 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(); 


my index.php in project folder





PHP Code:
<?php

// Valid PHP Version?
$minPHPVersion '7.2';
if (
phpversion() < $minPHPVersion)
{
die(
"Your PHP version must be {$minPHPVersion} or higher to run CodeIgniter. Current version: " phpversion());
}
unset(
$minPHPVersion);

// Path to the front controller (this file)
define('FCPATH'__DIR__ DIRECTORY_SEPARATOR);

// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath FCPATH 'app/Config/Paths.php';
// ^^^ Change this if you move your application folder

/*
*---------------------------------------------------------------
* 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
require $pathsPath;
$paths = new Config\Paths();

// Location of the framework bootstrap file.
$app = require rtrim($paths->systemDirectory'/ ') . '/bootstrap.php';

/*
*---------------------------------------------------------------
* 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(); 
Reply
#2

(This post was last modified: 05-15-2020, 01:26 PM by captain-sensible.)

i have three directories in /var/www/htdocs (apache on slackware current) each with a different project using CI4. The way i access each is via the i.p

I left .htacess in public alone since i'm using http for localhost and then tweak things for live. An example of my virtual host is:

<VirtualHost 127.0.0.2:80>
# ServerAdmin [email protected]



ErrorLog "/var/log/httpd/CI.org-error_log"
# CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
<Directory "/var/www/htdocs/CI/public">
Order allow,deny
Allow from All
AllowOverride All
Require all granted
</Directory>
ServerName CI.org
DocumentRoot "/var/www/htdocs/CI/public"
ServerAlias www.CI.org

</VirtualHost>


<VirtualHost 127.0.0.3:80>

so basically when i put 127.0.0.3 into address bar of browser i see my web page.


for the base url in app/config/app.php i use :

public $baseURL = 'http://127.0.0.3';
Reply




Theme © iAndrew 2016 - Forum software by © MyBB