【问题标题】:Configuring Codeigniter on Hostinger在 Hostinger 上配置 Codeigniter
【发布时间】:2015-06-02 17:12:56
【问题描述】:

我需要一些帮助来在我的免费主机上配置 Codeigniter。

我正在为我的网站使用 CodeIgniter 3.0 和 Hostinger。

我的 config.php 为:

    $config['base_url'] = 'http://mysite/';
    $config['index_page'] = '';
    $config['uri_protocol'] = 'AUTO';

我按照本主题所述配置 .htaccess:Codeigniter website 404 error / .htaccess

   RewriteEngine On
   RewriteCond %{REQUEST_URI} ^/system.*
   RewriteRule ^(.*)$ index.php?/$1 [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.+)$ index.php?/$1 [L]

即使这样,我仍然会从 Codeigniter 中找到 404 页面,我错过了什么?或者我做错了什么?我是这方面的新手,所以如果您需要看其他内容,请告诉我,我会上传。谢谢!

编辑:我忘了提到在我的本地主机中工作,但在现场是当我得到 404 错误时。

【问题讨论】:

  • 你能检查一下apache rewrite模块是否启用了吗?假设您使用的是 apache
  • 在直接向 Hostinger 提出的问题中,它说 mod_rewrite 默认启用:hostinger.ph/knowledge-base/99.html
  • 你设置了默认控制器吗?
  • 是的。在本地主机上工作正常,但在现场它让我得到 404 错误。
  • 您能看到您的 httpd.conf 的 DocumentRoot 和目录,或者更确切地说,这个特定网站的 Vhost 是什么?

标签: php .htaccess codeigniter hosting


【解决方案1】:

Error de .htaccess como se dice en este tema: Codeigniter sitio web 404 error / .htaccess... pues solo reemlazen con esto script .htaccess Funcional 100 x 100 en los 主机

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]

【讨论】:

【解决方案2】:

感谢 Ajeet Kumar 的帮助,我们设法找到了错误:

这似乎是 Hostinger 文件系统上区分大小写的问题,它在我的 localhost 上没有失败。

请务必记住以大写开头的 Controllers 和 Models 文件命名。

正如我之前所说,我是这方面的新手,并没有想到这一点,因为我的本地主机运行良好。感谢大家的帮助。

【讨论】:

    【解决方案3】:

    在 .htaccss 文件中写下这段代码

      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond $1 !^(index\.php|images|robots\.txt)
      RewriteRule ^(.*)$ index.php?/$1 [L]
    
    <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>
    

    在 Config.php 中

    $config['base_url'] ="YOUR_SITE_URL";//http://example.com/
    $config['index_page'] = 'index.php';
    $config['uri_protocol'] = 'AUTO';
    
    $config['encryption_key'] = 'SET_ANY_KEY_TO_USE_SESSION';
    

    还有database.php

    $db['default']['hostname'] = 'localhost';
    $db['default']['username'] = 'DB_USERNAME';
    $db['default']['password'] = 'DB_PASSWORD';
    $db['default']['database'] = 'DBNAME';
    $db['default']['dbdriver'] = 'mysql';
    

    【讨论】:

    • 不,还是一样的:c
    • 我从 CodeIgniter 得到 404 默认错误屏幕,我检查了 CodeIgniter 的日志文件夹,它没有显示任何内容/:
    • 在 config.php 文件中 $config['log_threshold'] = 4;然后检查日志
    • 错误 - 2015-03-29 19:38:30 --> 404 页面未找到:/index
    • 你的默认控制器设置在路由 ?$route['default_controller'] = "welcome";也检查一下stackoverflow.com/questions/18166496/…
    猜你喜欢
    • 2023-03-12
    • 2017-08-02
    • 1970-01-01
    • 1970-01-01
    • 2022-11-20
    • 2010-11-04
    • 2017-07-24
    • 1970-01-01
    • 2021-07-27
    相关资源
    最近更新 更多