Hide or Remove the public folder and index.php from codeigniter 4 URL is very simple, for that need to add some codes and we need to modify the folder structure. let me explain the detailed procedure the change the folder structure to remove public folder in codeigniter 4 URL with Windows XAMPP.
STEP 1 : Need Define BASEURL
public $baseURL = 'http://localhost/ci4/';
public $uriProtocol = 'REQUEST_URI';
Replace it with
public $uriProtocol = 'PATH_INFO';
STEP 2: Copy the index.php and .htaccess file from public folder
STEP 3 : Modify index.php file.
$pathsConfig = FCPATH . '../app/Config/Paths.php';
$pathsConfig = FCPATH . 'app/Config/Paths.php';
That's all, now you can access you project with out public folder and index.php.
STEP 4 : Apache conf file. (Rare case)
Even then, it is not working means, change some code in xampp apache (httpd.conf) file.
<Directory "E:/xampp/cgi-bin">
AllowOverride All
Options None
Require all granted
</Directory>
In the above code, AllowOverride All is there so no need to change anything. it will work smooth. if it was None, you need to change it to All
That's it, Now it will work smooth. if you have any doubts, comment below, i hope this tutorial is really helpful for you. stay connected for more tutorial like this.
No comments:
Post a Comment