代码之家  ›  专栏  ›  技术社区  ›  Mohammed Sabir

Codeigniter 3.1.6-如何删除索引。来自url的php

  •  4
  • Mohammed Sabir  · 技术社区  · 8 年前

    我正在开发codeigniter 3.1.6。

    我还改变了 base_url 路径到我的项目路径,删除了 index.php index_page 并改变了 url_protocol REQUEST_URI .

    不过,当我将url重定向到任何控制器方法时,它会抛出一个错误' The page you requested was not found

    如果我在胡闹 /index.php 在base_url的末尾,它可以工作,但它是错误的。它应该在没有索引的情况下工作。php。只有3.1.6给出了这个问题。

    注意:codeigniter-3.1.4工作正常,但此版本存在问题

    5 回复  |  直到 8 年前
        1
  •  3
  •   Yadhu Babu    8 年前

    更改文件夹名称 CodeIgniter-3.1.6 ci

    设置您的 base_url

    $config['base_url'] = 'http://localhost/ci/
    

    .htaccess

    RewriteEngine On
    RewriteBase /ci
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    
        2
  •  2
  •   Harish    8 年前

    在中使用此脚本。htaccess

    <IfModule mod_rewrite.c>
       RewriteEngine On
       # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
      #  slashes.
      # If your page resides at
      #  http://www.example.com/mypage/test1
      # then use
      # RewriteBase /mypage/test1/
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
    
      RewriteRule ^(.*)$ index.php?/$1 [L]
      # If your root folder is at /mypage/test1/
      RewriteRule ^(.*?)$ /mypage/test1/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>
    

    去除 index.php 从…起 config.php $config['index_page'] = '';

        3
  •  1
  •   faisal    8 年前

    1) 编辑配置。php

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

     $config['index_page'] = '’;
    

    2) 创建/编辑。htaccess文件

     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ index.php/$1 [L]
    
        4
  •  0
  •   Majid Saddique    8 年前

    1: 创建。根目录中的htaccess文件不是另一个项目文件夹目录。

    2: 编写或复制此代码并粘贴

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

    我希望这能正常工作。 进入配置文件并进行更改

        5
  •  0
  •   munyao    6 年前

    附加提示:确保。h根文件夹中的访问不在内部>应用程序文件夹