CodeIgniter Forums

Full Version: Problems with CodeIgniter 4.0.4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi, I just download the CI4 and the only way a page loads is wen I use the URL

http://localhost/CI4/public

I'm using WAMP, with PHP 7.2.14, and the mod_rewrite is ok. Also tried to change

$indexPage = 'index.php'; to 'index.php?'

But doesn't work.

I actually following the tutorial, static pages.

Nothing I've tried works. Help.

Thanks in advance
in your command prompt, navigate into the root folder and enter the following command

php spark serve

If you want to avoid the index.php, create a .htaccess file and put the following code there:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Hope this helps
Thanks, but that's for use the native server of CI4. I want to use WAMP.
(09-02-2020, 05:33 PM)Omar Crespo Wrote: [ -> ]Thanks, but that's for use the native server of CI4. I want to use WAMP.

The design of CI has changed. Nevertheless you can setup a virtual host on your machine, that will help you to access the site with an address like http://myproject.test.

CI 4 is great, using it for my third project now.

Thanks
(09-02-2020, 12:57 PM)Omar Crespo Wrote: [ -> ]But doesn't work.

What is the thing that doesn't work? The error you have? Or is it just a blank page?
(09-02-2020, 02:47 PM)chenzen Wrote: [ -> ]in your command prompt, navigate into the root folder and enter the following command

php spark serve

If you want to avoid the index.php, create a .htaccess file and put the following code there:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Hope this helps

CodeIgniter 4 comes with an .htaccess file.
(09-03-2020, 12:51 AM)demyr Wrote: [ -> ]
(09-02-2020, 12:57 PM)Omar Crespo Wrote: [ -> ]But doesn't work.

What is the thing that doesn't work? The error you have? Or is it just a blank page?
When I use my baseurl

http://localhost/CI4 all I get is the index of/

When I call any method like it used to be:

http://localhost/CI4/index.php/home/index

The error is:

The requested url /CI4/index.php/home/index was not found on this server.
You may need to change the .htaccess file.

Code:
# from this to the below
RewriteRule ^(.*)$ index.php/$1 [L]

# Change to this on some servers
RewriteRule ^(.*)$ index.php?/$1 [L]

And do not forget that the base url needs to end with a forward slash.
(09-06-2020, 06:19 AM)InsiteFX Wrote: [ -> ]You may need to change the .htaccess file.

Code:
# from this to the below
RewriteRule ^(.*)$ index.php/$1 [L]

# Change to this on some servers
RewriteRule ^(.*)$ index.php?/$1 [L]

And do not forget that the base url needs to end with a forward slash.
Thanks but that whasn't the problem.

I kind of solve it by adding public folder to my base url. That should be included in the guide.
Instead of
$baseURL = http://localhost/CI4/

It works with:
$baseURL = http://localhost/CI4/public/

Where can I download the .zip guide of CI4?? Here in my country (Cuba) we have veeery limited online access, so it would be great to read it offline. Thanks
You should set your virtualhost config (documentroot and directory directives) to point to the public folder then it will work and /public doesnt need to be added to the end of the URL. See my config below:

Code:
<VirtualHost ng-cms.local:80>
    DocumentRoot    "D:\vhosts\ng-cms.local\public"
    ServerName      ng-cms.local
    ServerAlias     www.ng-cms.local
    <Directory "D:\vhosts\ng-cms.local\public">
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>
Pages: 1 2