codeigniter and cpanel installation

若如初见. 提交于 2019-12-02 11:25:38

问题


I am completely new to moving codeigniter to my web-server and im having trouble with the configuration. Where do I place my codeigniter project folder in www under myurl.com in in the very root directory? Am i supposed to move out the application and system folders?

I am trying to remove index.php? from my URL name where do i place my .htaccess file in the root or in the same folder as my codeigniter directory?

I wish to be able to type in (www.myurl.com) and be redirected to my home_controller/index is this possible?

below is my .htaccess file in it's entirety

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /MMSFL/


#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]


#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

<IfModule !mod_rewrite.c>


ErrorDocument 404 /index.php
</IfModule>

I have also made the following changes in config/routes

    $config['index_page'] = "";
    $config['base_url'] = "http://myurl.com/";
    $config['server_root'] = $_SERVER['DOCUMENT_ROOT'];
    $config['uri_protocol'] = 'AUTO';

$route['default_controller'] = "home_controller";

回答1:


Directory structure

If at all possible, it's advised that you keep your system and application folders above the web root. Your index.php file needs to be accessible from a browser, so that should go in your public_html folder. Here's a possible directory structure that you could use:

-/home/edd
    -public_html
        -index.html
        -.htaccess
    -system
    -application

You can rename your system and application folders, or create another sub-directory to put them in, if you want.


index.php

Within index.php you'll need to update $system_path and $application_folder to reflect the location and name of your system and application folders. You can use an absolute path or a relative path. Relative path shown below:

$system_path = '../../system';
$application_folder = '../../application';

.htaccess

The first two sections of your .htaccess file are there to prevent a user from accessing your system and application folders. If you're storing them above the web root then you don't really need this. If you keep them, then you need to update the paths. This file should be located in your public_html folder.


application/config/config.php

As you've already correctly done, the index.php value should be removed from the index_page config, so index.php can be removed from your url using your .htaccess file;

$config['index_page'] = 'index.php';

should be changed to:

$config['index_page'] = '';

You may also have to make this change:

$config['uri_protocol'] = 'REQUEST_URI';

(If you have no luck with this value, try the others. One should work!)


application/config/routes.php

$route['default_controller'] = "home_controller";

(Assuming that is the name of your controller.)


Your site is likely to depend on some assets, such as CSS and JavaScript. These should go in your web root - public_html. You can organise these file however you like.




回答2:


Move all the files that reside inside your CI-folder into public_html. The .htaccess file should be located in the root of public_html(where application, system, index.php etc also reside).

Side note: don't put $config values in /config/routes.php - those need to be in /config/config.php



来源:https://stackoverflow.com/questions/12282450/codeigniter-and-cpanel-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!