我的代码Igniter可以';t从index.php跳转到正确的地址


my codeIgniter can't jump to the right address from the index.php

我的codeIgniter索引地址是localhost/codeIgniter_2.2.0/如果我点击索引页面上的[LOGIN]按钮,浏览器将跳转到localhost/index.php/LOGIN。但是localhost/codelighter_2.2.0/index.php/login是正确的地址。我添加到.htacess

RewriteEngine On  

RewriteBase /codeigniter_2.2.0/

但它仍然不起作用。有什么解决办法吗?thx!

在config/config.php 中

1: $config['base_url'] = 'http://localhost/project-name/';

2: $config['index_page'] = '';

确保您已经配置了路由.php

在主目录中尝试这些htaccess

第一个

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index'.php|images|robots'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

第二个

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    #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 [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>

第三个

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    #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 [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>
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

第四个

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
RewriteEngine On  
RewriteBase /codeigniter_2.2.0/
 to 
empty, means remove all in your htaccess

我认为在这种情况下,不需要设置htaccess,它会自动尝试这个