Remove /public from URLs |
Hi everyone, I was wondering if there is any official documentation / way to remove the public from the urls.
I remember CI3 having a separate section where it stated the lines to be added to the .htaccess file in order to remove the index.php and keep all the benefits without compromising security or design. Couldn't get to the same information when migrating to CI4. Any help on this matter is really appreciated. Thank you all.
Hi there,
You will find htaccess and index.php files under Public folder. Move them to the main folder and open the index.php with your code editor. Line 20 (or sth) you will see Code: $pathsConfig = FCPATH . '../app/Config/Paths.php'; here remove the ../ at the beginning and it will be 'app/Config/Paths.php'; That's all. PS : Don't forget to remove index.php string in your App file under Config as usual (Line 39): Code: public $indexPage = '';
I don't know why many people suggest removing index from public to outside that is not the right way only .htaccess can work for Appache here you go don't touch anything just copy this to .htaccess game over (here we have hidden public folder with.htaccess)
Code: RewriteEngine On then go to App/config/app just remove (index.php) to the plain game over enjoy your c_i 4+ whether local or on live server Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
(02-15-2022, 12:40 AM)luckmoshy Wrote: I don't know why many people suggest removing index from public to outside that is not the right way only .htaccess can work for Appache here you go don't touch anything just copy this to .htaccess game over (here we have hidden public folder with.htaccess)How can i start project in localhost , with php spark serve or simply view the folder in localhost ? .htaccess must be only this 5 rows ? if i use .env file must change public $indexPage = ''; ? (02-15-2022, 12:43 PM)pippuccio76 Wrote:(02-15-2022, 12:40 AM)luckmoshy Wrote: I don't know why many people suggest removing index from public to outside that is not the right way only .htaccess can work for Appache here you go don't touch anything just copy this to .htaccess game over (here we have hidden public folder with.htaccess)How can i start project in localhost , with php spark serve or simply view the folder in localhost ? .htaccess must be only this 5 rows ? if i use .env file must change public $indexPage = ''; ? There is one (.htaccess) in public just leave it Create a new .htaccess in the app root take that code above and paste in it now you are right to go whatever way Php spark or else Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
(02-15-2022, 12:40 AM)luckmoshy Wrote: I don't know why many people suggest removing index from public to outside that is not the right way only .htaccess can work for Appache here you go don't touch anything just copy this to .htaccess game over (here we have hidden public folder with.htaccess)its not working for 4.4.3 version can you suggest ant thing
See manual https://codeigniter4.github.io/CodeIgnit...x-php-file
It works
.htaccess
Code: # Remove index.php from URL What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |