Welcome Guest, Not a member yet? Register   Sign In
Problems with CodeIgniter 4.0.4
#1

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
Reply
#2

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
Reply
#3

Thanks, but that's for use the native server of CI4. I want to use WAMP.
Reply
#4

(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
Reply
#5

(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?
Reply
#6

(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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(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.
Reply
#8

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

(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
Reply
#10

(This post was last modified: 09-06-2020, 06:05 PM by orionstar.)

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>
Reply




Theme © iAndrew 2016 - Forum software by © MyBB