CodeIgniter showing only default controller

后端 未结 15 2867
-上瘾入骨i
-上瘾入骨i 2021-02-14 21:59

I am using Codeigniter in Local WAMP. Here code is working fine. But i upload in Cpanel ( inside of example.com, folder name call \'mysite\'). Ther

相关标签:
15条回答
  • 2021-02-14 21:59

    try this

    $config['uri_protocol'] = 'PATH_INFO';
    $config['enable_query_strings'] = FALSE;
    

    Httaccess

    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    #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 [NC]
    </IfModule>
    
    0 讨论(0)
  • 2021-02-14 22:06

    If you plan to use subfolder on server do the same on local WAMP. This way you can test it before you send it on server.

    I was using CI long time ago but I think you have to add mysite/ in some config file.

    See: Installing a CodeIgniter application in a subfolder

    0 讨论(0)
  • 2021-02-14 22:07

    I solved the same issue by changing the controller file name to start with a capital letter.

    Just like the default 'Welcome' controller downloaded.

    0 讨论(0)
  • 2021-02-14 22:09

    Remove

    $route['user/(:any)'] = 'user/index';
    

    in your routes.php file. user/signin matches the above condition, that is why CI route the request to user/index instead of your "User" controller "signin" function.

    What are you trying to achieve with that route configuration?

    0 讨论(0)
  • 2021-02-14 22:13

    .htaccess Code

    Restore the default config to config.php, Hope this helps you.

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]
    
    0 讨论(0)
  • 2021-02-14 22:13

    I used following .htaccess file and it works for me with cpanel.

    # index file can be index.php, home.php, default.php etc.
    DirectoryIndex index.php
    
    # Rewrite engine
    RewriteEngine On
    
    # condition with escaping special chars
    RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
    
    0 讨论(0)
提交回复
热议问题