CodeIgniter Forums
always index - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: always index (/showthread.php?tid=87967)



always index - klarez - 06-28-2023

Hello, my problem is: my index.php file is in public folder ,my view about.php is in Views folder. I made a Controller About.php 
PHP Code:
<?php

    
namespace App\Controllers;  
    
class About extends BaseController{

        public function  index() {
            return view('about');
        }
    }
?>

with route 
$routes->get('/about','About::index');

but when i click on about page in URL is virtualhostrname/about.php but the index is always displayed.
.htacces file is ok rewrite engine is on 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule^([\s\S]*)$ index.php/$1 [L,NC,QSA] 

.env
app.$baseURL='htttp://virtualhostname/'

in app config
public string $baseURl='http://virtualhostname/'

and always is index page  and in url is virtualhostname/about.php


        }



RE: always index - kenjis - 06-28-2023

The URL should be http://virtualhostname/about
Not http://virtualhostname/about.php

Try the official tutorial:
https://codeigniter4.github.io/CodeIgniter4/tutorial/index.html