codeigniter和cpanel安装 [英] codeigniter and cpanel installation

查看:237
本文介绍了codeigniter和cpanel安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个全新的移动codeigniter到我的网络服务器和我有配置的麻烦。我在哪里放置我的codeigniter项目文件夹在www下myurl.com在根目录中?我应该移出应用程序和系统文件夹?



我要删除index.php吗?从我的URL名称在哪里放置我的.htaccess文件在根或在同一个文件夹作为我的codeigniter目录?



我希望能够输入.myurl.com)并重定向到我的home_controller / index
是可能的吗?





下面是我的.htaccess文件完整 >

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


如果已重命名系统文件夹,可以替换'system'。
RewriteCond%{REQUEST_URI} ^ system。*
RewriteRule ^(。*)$ /index.php/$1 [L]


#到您的应用程序文件夹名称。
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>



我也在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;


解决方案

目录结构 p>

如果可能,建议您保留系统申请文件夹上面的web根。您的 index.php 文件需要从浏览器访问,因此应该放在您的 public_html 文件夹中。以下是可以使用的可能的目录结构:

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

您可以重命名您的系统和应用程序文件夹,或者如果愿意,可以创建另一个子目录。






index.php



index.php code> $ system_path 和 $ application_folder 以反映系统和应用程序文件夹的位置和名称。您可以使用绝对路径或相对路径。相对路径如下所示:

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






.htaccess / p>

.htaccess 文件的前两个部分用于阻止用户访问您的系统和应用程序文件夹。如果你把它们存储在web根目录之上,那么你不需要这个。如果你保留它们,那么你需要更新路径。此文件应位于您的 public_html 文件夹中。






strong> application / config / config.php



正如你已经做的那样, index.php value应该从 index_page 配置中删除,因此可以使用您的 .htaccess 从您的网址中删除index.php / em>文件;

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

应更改为:

  $ config ['index_page'] =''; 

您可能还需要进行此更改:

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

(如果你没有运气这个值,试试别人, p>




application / config / routes.php

  $ route ['default_controller'] =home_controller; 

(假设是您的控制器的名称。)






您的网站可能依赖于某些资产,例如CSS和JavaScript。这些应该在你的web根 - public_html 。您可以随意组织这些文件。


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";

解决方案

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.

这篇关于codeigniter和cpanel安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆