代码之家  ›  专栏  ›  技术社区  ›  Bernando Purba

Codeigniter只能显示默认控制器

  •  0
  • Bernando Purba  · 技术社区  · 6 年前

    配置:

    $config['base_url'] = 'https://*****.net/my_project/';
    $config['index_page'] = '';
    $config['uri_protocol'] = 'REQUEST_URI';
    $config['enable_hooks'] = FALSE;
    $config['encryption_key'] = 'xRUqKhsoZ5qV6y3kqARFJFdPqJvp7X2z';
    $config['sess_driver'] = 'files';
    $config['sess_cookie_name'] = 'ci_session';
    $config['sess_expiration'] = 7200;
    $config['sess_save_path'] = sys_get_temp_dir();
    $config['sess_match_ip'] = FALSE;
    $config['sess_time_to_update'] = 300;
    $config['sess_regenerate_destroy'] = FALSE;
    

    路线:

    $route['default_controller'] = 'main';
    $route['404_override'] = '';
    $route['translate_uri_dashes'] = FALSE;
    

    我试过几次了。htaccess:

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

    <IfModule mod_rewrite.c>
    
    RewriteEngine On
    
    # Set the rewritebase to your CI installation folder
    RewriteBase /sandbox/ci/
    
    
    # Send everything to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    
    </IfModule> 
    

    任何帮助都将不胜感激。谢谢!

    3 回复  |  直到 6 年前
        1
  •  0
  •   Pradeep    6 年前

    试试这个,对我有用。确保该文件必须名为Yourcontroller.php,大写字母Y。

    .htaccess接口

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

    $autoload['helper'] = array('url', 'file');
    

    请在此处签出控制器命名约定: https://www.codeigniter.com/userguide3/general/controllers.html . 希望这对你有帮助。

    招呼!

        2
  •  0
  •   Rudra    6 年前

    这是正常的问题,要修复它,您必须在文件夹中定义.htaccess文件。如下图所示 两个文件都在你的文件夹中。 将此文件放入主文件夹并指定.htaccess的名称

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

    将此文件放入应用程序文件夹并指定.htaccess的名称

    <IfModule authz_core_module>
      Require all denied
    </IfModule>
    <IfModule !authz_core_module>
      Deny from all
    </IfModule>
    
        3
  •  0
  •   keyur sidhdhapara    6 年前
    1) first controller name and class name first character capital letter
       example :: CapturistaCtrl
    2) go to config changes ::
       -> $config['index_page'] = 'index.php'; remove index.php
       -> $config['uri_protocol']   = 'REQUEST_URI'; remove (REQUEST_URI)
    3) .htaccess
       <IfModule mod_rewrite.c>
           RewriteEngine On
           RewriteCond $1 !^(index\.php|resources|robots\.txt)
           RewriteCond %{REQUEST_FILENAME} !-f
           RewriteCond %{REQUEST_FILENAME} !-d
           RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
       </IfModule>
    
    set .htaccess file 
    
    List item