codeigniter链接无法正常工作

时间:2015-06-29 09:07:21

标签: php codeigniter

我在此链接上安装了codeigniter网站:http://localhost/shivnath/并且此网址正常运行。站点有一个控制器名称站点 如下

class Site extends CI_Controller {

 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  *         http://example.com/index.php/welcome
  * - or -
  *         http://example.com/index.php/welcome/index
  * - or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
  public function index()
  {
    $this->home();
  }


  public function home()
  {

    $this->load->view('templets/header');
    $this->load->view('pages/home');
    $this->load->view('templets/footer');

  }
}

当我打开此链接时:localhost/shivnath/index.php/site网站无法正确加载。虽然在此链接localhost/shivnath/上加载了相同的控制器,但它在此链接上工作正常。

3 个答案:

答案 0 :(得分:0)

使用set grandparent to POSIX file (POSIX path of ((POSIX file (POSIX path of ((path to me as text) & "::")) as text) & "::")) as text 代替redirect('site/home');

答案 1 :(得分:0)

是config

中的文件routes.php
$route['default_controller'] = 'welcom';

更改为

$route['default_controller'] = 'site';

删除index.php

file config.php - &gt;找到第32行

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

更改为

$config['index_page'] = '';

和文件.htaccess

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

答案 2 :(得分:0)

根据您的codeigniter版本,在编码服务器3上,您需要检查所有控制器和模型是否在文件和类名称上以大写字母作为大写字母。

用于加载CSS和图像以及js

首先在application / config / autoload.php

中自动加载url帮助器

然后在主目录中添加资源文件夹,将所有css和图像放在该文件夹中,您可以在资源文件夹中包含子文件夹。

然后尝试将css资产放在标题

 public static Bitmap GetDesktopImage()
    {
        //In size variable we shall keep the size of the screen.
        SIZE size;

        //Variable to keep the handle to bitmap.
        IntPtr hBitmap;

        IntPtr hDC = PlatformInvokeUSER32.GetDC(PlatformInvokeUSER32.GetDesktopWindow());

        IntPtr hMemDC = PlatformInvokeGDI32.CreateCompatibleDC(hDC);

        size.cx = PlatformInvokeUSER32.GetSystemMetrics(PlatformInvokeUSER32.SM_CXSCREEN);

        size.cy = PlatformInvokeUSER32.GetSystemMetrics(PlatformInvokeUSER32.SM_CYSCREEN);

        hBitmap = PlatformInvokeGDI32.CreateCompatibleBitmap(hDC, size.cx, size.cy);

        if (hBitmap != IntPtr.Zero)
        {

            IntPtr hOld = (IntPtr)PlatformInvokeGDI32.SelectObject(hMemDC, hBitmap);

            PlatformInvokeGDI32.BitBlt(hMemDC, 0, 0, size.cx, size.cy, hDC, 0, 0, PlatformInvokeGDI32.SRCCOPY);

            PlatformInvokeGDI32.SelectObject(hMemDC, hOld);

            PlatformInvokeGDI32.DeleteDC(hMemDC);

            PlatformInvokeUSER32.ReleaseDC(PlatformInvokeUSER32.GetDesktopWindow(), hDC);

            Bitmap bmp = System.Drawing.Image.FromHbitmap(hBitmap);

            PlatformInvokeGDI32.DeleteObject(hBitmap);

            GC.Collect();

            return bmp;
        }


        return null;
    }

如果您尚未从配置设置中删除index.php,则每次需要在url中包含index.php时。

<?php echo base_url('assets/css/stylesheet.css');?>

如果删除index.php,可以从这里获得一些.htacess。https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter