kenjis / codeigniter-composer-installer

Installs the offical CodeIgniter 3 with secure folder structure via Composer
MIT License
377 stars 118 forks source link

Removing the public url #12

Closed deogit closed 7 years ago

deogit commented 7 years ago

Hi don't get the last issue for this.

How can I remove the public folder? I just tried to remove the public folder and move .htaccess and index.php in root folder "htdocs\kenjis" just like the original setup of Code Igniter when you extracted it . Here' the error I've encountered

"Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php"

What should I do? Thank you.

kenjis commented 7 years ago

This installer creates public folder intentionally and changes some configs for it. If you don't use public folder, I recommend you not use this installer. And I recommend you not to remove the public folder. The original setup of CodeIgniter is not secure. CodeIgniter4 would have public folder.

If you still want to remove the public folder, see what this installer do https://github.com/kenjis/codeigniter-composer-installer/blob/master/src/Installer.php#L32.

indrakaw commented 7 years ago

Ayy @deogit. I see the problem: You are using shared-hosting instead of VPS, aren't you? Developing PHP without framework is painfull, but most them doesn't support shared-hosting. That's why CI is popular amongst devs that doesn't want to pay extra cost or painfull setup for a blog or simple web-app.

Here's the solution, choose one of them:

  1. Create a .htaccess file on root project above public/:
    
    # This .htaccess is for shared-hosting, that usually located on public_html/
    # this will brings public/ dir into root. If you're using VPS, then delete this file.
RewriteEngine On # This will move-up public folder RewriteRule ^(.*)$ public/$1 [L] # This will hide dot files RewriteCond %{THE_REQUEST} ^.*/\. RewriteRule ^(.*)$ - [R=404]

2. Bring-up `index.php` (or `.htaccess` too) inside `public/` dir into root project. Then, change few lines inside `index.php` into:
```php
$system_path = '../vendor/codeigniter/framework/system';

into

$system_path = 'vendor/codeigniter/framework/system';

and

$application_folder = '../application';

into

$application_folder = 'application';

As Kenjis mentioned above.

Also, most shared-hosting doesn't support git and/or composer installation. You have to install it locally then upload it manually via FTP. Painful, isn't it?