#08 Removing public and index.php from URL | CodeIgniter 4 Tutorials
HTML-код
- Опубликовано: 7 дек 2024
- Step 1: Open App.php File from the Location: c:/xampp/htdocs/ci4/app/Config/App.php
public $baseURL = 'localhost:8080'; To
public $baseURL = 'localhost/your_project_name/';
Step2:
public $uriProtocol = 'REQUEST_URI'; To public $uriProtocol = 'PATH_INFO';
Step3:
In public/ directory, copy index.php and .htaccess to your root project directory.
Step4: Open index.php from project root directory, and edit the following path:
$pathsPath = FCPATH . '../app/Config/Paths.php'; To
$pathsPath = FCPATH . 'app/Config/Paths.php';
ගොඩක් ස්තුතියි!! Thank you so much. it is very help full
sirji nice tutorial really ...
when i watch this videos i am hearing a sound of house cricket🦟🦟. and thinking that there is a house cricket🦟🦟 in my house 😀😀😀. By the way I learned complete CI4 from you. Thank you so much
Can you help me find 404 error? displaying according to your this session.
Muchas Gracias !!! Bendiciones!!! nueva suscriptora
It works Thanks for saving my time.😀
Hi,
I have done everything that you mention. but still "/public" segment visible in my URL when it echo.
what should I do?
Sir i am getting error page not found or access denied
With ci3, I unzip the file into the project folder, adjust the base_url, and I'm pretty much off to the races.
This ci4 is turning into a cluster f**k, and no matter what I do, and how many tutorials I watch, all say the same thing, and end in the same result.
Whoops!
We seem to have hit a snag. Please try again later...
If it worked for ci3 it should work for ci4. Oh! I'm going to try again later... much later.
Thank you for this video, it helped me a lot!!! 🙏🙌
Hi sir
I have done changes everything you have mentioned but still I am facing the 404 issue and my php version is 8.0.19 .Thank you
so good. but how about utf-8? where should i define that to cover all pages?
if you have header.php view, define utf-8, in that file
Is our web app still secure if we remove public folder and index.php file from urls? Please reply.
Definitely Secure...
But one thing , The security of an application will always depends up on The Developer
The "public" folder in CI4 is intentionally created so that users can only access to this directory not the root directory. So copying the index file to your root directory will make it CI 3 again, so is not a good option. Better you set www.yourdomain.com/public as root directory in your live server. No need to modify anything. I've already tested.
@@chandangour7488 Right..
Yes ci 4 have use it for preventing... file path traversal vulnerability... Using old ci3 method makes it vulnerable.. There is also other method for preventing vulnerability ... But method use by ci4 is best to my knowledge..
Hi and Thanks for the tutorials. Is this method safe while uploading on a live server?
Glade to see your comprehensive lecture. I have done everything you instructed but it's not working. it gives a 404 error. please give us some solution of this???
When I am upload my project on server css & js work perfect but controller access with index.php please help me into this
Default page is opening properly , but browsing the controller name giving this error. 404
Sorry! Cannot seem to find the page you were looking for. Any one fixed this issue? Please help to resole this in CodeIgniter 4.3.2 in IIS server with PHP 8.2.1
same, did you solve it
@@sumayaazadjerin2063 same brother
How to solve it?
your are telling ci4 clearly sir
Thank You
Please note everyone: This tutorial is not applicable for new version of codeigniter4. such as version 4.3.6. Lot of things have changed. You need to add every controller to route.php file in order to view the page in the browser. If you need an updated tutorial, I will create and upload for you. Please let me know in the comment reply section. Thank you
Pls make new tutorials, thanks in advance
Please make new tutorial, my problem are routes. Nothing works...
just set autoroute true and problem solved
May you share the slide that you tech? Thanks
hi i want to suggest something ............please please error resolve bhi krny ka bataye please
Thanks for the video
Sir please tell me how to set dynamic baseurl, in the live
open your App.php from Project\app\Config folder
find the property and assign your live URL like below:
public $baseURL = "youdomain.com"
@@GoPHP thank you sir
Notice the new version of index.php file is like this :
// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure.
//require FCPATH . '../app/Config/Paths.php';
require FCPATH . 'app/Config/Paths.php';
// ^^^ Change this line if you move your application folder
$paths = new Config\Paths();
you got any solution for this?
This removes the entire purpose of routing stuff through a public folder..
Not working for me
is work using version 4.4.1
not sure
Hello sir, I have changed all the steps you have followed but still getting a 404 error. anyone can please suggest to me what I do I am using Windows, and Codeigniter 4 development on vs code with xampp server.
i doesnt work
now works on localhost..
i just enable rewrite module:
1)
a2enmod rewrite
service apache2 restart
2)
then add script below in /etc/apache2/sites-available/000-default.conf
AllowOverride all
service apache2 reload
3)
open your project
localhost/coddeigniter4/public/user/login
You dont have permission to access this resource
thanks!