繁体   English   中英

将codeigniter项目上载为服务器的子域

[英]uploading codeigniter project as subdomain of server

我已经看到过类似的问题,但是我尝试了所有这些问题的答案,但是它们无法正常工作,所以我不得不为此问题感到抱歉

我正在尝试将基于Codeigniter的项目上载到服务器,但是显示404页面,但未显示错误,但我可以看到收藏夹图标

最新的htaccess是

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

配置.php的前几行是

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://demos.ededge.in/';

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

我上传到名为demos的文件夹

跟着这些步骤:

1)控制器类别名称应以大写开头。

2)文件名应以大写字母开头。

因为Linux区分大小写。

基本设置过程:

1)首先,您需要将子域指向托管服务器上的特定文件夹路径。

2)将代码上传到指定的子域文件夹路径。

3)检查文件夹和文件所有者组以及权限。 文件夹权限755和文件权限644。

4)创建数据库并导入数据库SQL文件。

5)在/application/config/config.php中配置BASE_URL

$config['base_url'] = 'http://sub-domain.domain.com/';

6)更改配置文件中的加密密钥

$config['encryption_key'] = 'to_any_16_character_alpha_numeric_special_character';

注意:不要在密钥中使用“ $”。 PHP考虑作为变量。

7)在/application/config/database.php中配置数据库连接

$db['default']['hostname'] = "database_hostname";
$db['default']['username'] = "database_username";
$db['default']['password'] = "database_password";
$db['default']['database'] = "database_name";
$db['default']['dbdriver'] = 'database_driver';

注意:-您需要在创建的数据库中为数据库用户分配适当的权限。 -选择适当的数据库驱动程序名称,例如“ mysqli”。

8)如果您不想在URL中使用index.php,请检查.htaccess代码。 重写模块的基本.htaccess代码

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM