Welcome Guest, Not a member yet? Register   Sign In
request URL not found
#1

(This post was last modified: 04-30-2024, 06:54 PM by kenjis.)

Hi guys, I am struggling to make my CI4 app to work properly in an internal LAN linux machine, I have installed Apache,php 8.3 and mySql in xubuntu 22.04 LTS
The rewrite mod is enable in Apache.
I made several tries with a a .conf file in /etc/apache2/sites-enabled, nothing work. My current file is
I do sudo a2ensite and the filename and restart apache2

Code:
<VirtualHost *:80>
    #ServerName 192.168.0.18
  ServerAlias /b2bci4
  DocumentRoot "/var/www/html/b2bci4/public"
    <Directory "/var/www/html/b2bci4">
        Options Indexes FollowSymLinks MultiViews
        #Options  +FollowSymLinks
        AllowOverride All
        #Order allow,deny
        #allow from all
        Require all granted
  </Directory>
</VirtualHost>

I have place an .htaccess file like in the CI4 web site
Code:
#RewriteEngine On
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
<FilesMatch "^\.">
    Require all denied
    Satisfy All
</FilesMatch>

In app/Config/App.php I have public string $baseURL = 'http://192.168.0.18/b2bci4/public/';

I can get the login screen but when I click submit to the controller Login/doLogin I got 404... All is working right in my xampp when I start spark server and do http://localhost:8080

Can someone point me what I am doing wrong please?

Thank you all!
Reply
#2

mainPath .htaccess

RewriteEngine On

RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]

RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

public path in .htaccess
.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
Reply
#3

I recommend to read the official documentation:
https://codeigniter4.github.io/CodeIgnit...ith-apache
Reply
#4

(This post was last modified: 04-30-2024, 02:00 AM by jcarvalho.)

(04-29-2024, 05:16 PM)mywebmanavgat Wrote: mainPath .htaccess

RewriteEngine On

RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]

RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

public path in .htaccess
.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
Hi! Thank you for this tips but didnt work. Same problem

(04-29-2024, 05:38 PM)kenjis Wrote: I recommend to read the official documentation:
https://codeigniter4.github.io/CodeIgnit...ith-apache

Hi Sir, thanks for the reply but I got those .htaccess fragments from the official documentation, because they didnt work, I posted my problem here to see if someone could help me out. I dont know much about Apache, just basic stuff. I just copy and pasted code from documentation
Reply
#5

(This post was last modified: 04-30-2024, 05:50 AM by xsPurX.)

IF your using ci 4.5 check in app/config/routing.php that autoroutes is turned on.

public bool $autoRoute = true;

Not sure why in Ci 4.5 they have it off by default.
Reply
#6

Your configuration is "Hosting with VirtualHost".
https://codeigniter4.github.io/CodeIgnit...irtualhost

Apache configuration sample:
Code:
<VirtualHost *:80>
    DocumentRoot "/opt/lamp/apache2/myproject/public"
    ServerName  myproject.local
    ErrorLog    "logs/myproject-error_log"
    CustomLog    "logs/myproject-access_log" common

    <Directory "/opt/lamp/apache2/myproject/public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

The CI4 default .htaccess in public/:
Code:
# Disable directory browsing
Options -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...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [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 ^([\s\S]*)$ index.php/$1 [L,NC,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
Reply
#7

i would ask what exactly is your objective ?
im on linux for development my url are 127.0.0.x ,so are you trying to have your PC act as a server to the public or are you just developing ?
CMS CI4     I use Arch Linux by the way 

Reply
#8

(05-01-2024, 09:04 AM)captain-sensible Wrote: i would ask what exactly is your objective ?
im on linux  for development my url are  127.0.0.x  ,so are you trying to have your PC act as a server to the public  or are you just developing ?

Hi! What I want to do is setup an vmware machine on a company costumer and host the site for internal use only.
So I first asked a colleague to create a vmware machine in our LAN for me to test the site. If all works, then export the machine and import it on the costumer LAN. the site works great in my W11 machine using xampp and start a server with php spark serve, but not in the vmware machine
Reply




Theme © iAndrew 2016 - Forum software by © MyBB