【问题标题】:my codeIgniter can't jump to the right address from the index.php我的 codeIgniter 无法从 index.php 跳转到正确的地址
【发布时间】:2015-05-02 07:43:13
【问题描述】:

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

RewriteEngine On  

RewriteBase /codeigniter_2.2.0/

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

【问题讨论】:

    标签: php codeigniter url-rewriting


    【解决方案1】:

    在 config/config.php 中

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

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

    确保您已配置您的 routes.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]
    

    【讨论】:

    • 他刚刚给了你所有的选择/可能性.. :) 尝试一下
    【解决方案2】:
    RewriteEngine On  
    
    RewriteBase /codeigniter_2.2.0/
    
     to 
    
    empty, means remove all in your htaccess
    

    我认为在这种情况下不需要设置自动获取的htaccess试试这个

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-11
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多