2016-02-04 95 views
1

我試過我在堆棧溢出這裏找到的每個解決方案,但沒有成功。Codeigniter刪除index.php - htaccess本地主機

我跑

  • 贏8.1和
  • 笨3.0.4

使用Smarty 3的最新版本

  • XAMPP V3.2.1所有這一切工作罰款直到我試圖從網址中刪除'index.php'。

    的config.php

    $config['base_url'] = 'localhost'; 
    
    $config['index_page'] = ''; 
    

    routes.php文件

    $route['default_controller'] = 'home'; 
    
    $route['contact'] = 'contact'; 
    

    的.htaccess

    <IfModule authz_core_module> 
        Require all denied 
    </IfModule> 
    <IfModule !authz_core_module> 
        Deny from all 
    </IfModule> 
    <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 /responsive_template/ 
        RewriteEngine on 
        RewriteCond $1 !^(index\.php|images|robots\.txt) 
        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> 
    

    Apache的的LoadModuleř ewrite_module模塊/ mod_rewrite.so「啓用

    <Directory /> 
    
        AllowOverride all 
    
        Require all denied 
    
    </Directory> 
    

    如果我訪問localhost/responsive_template/index.php/contact一切工作正常,只有localhost/responsive_template/contact以404結束,僅此而已。

    整個CodeIgniter的應用程序文件夾是在c:\xampp\htdocs

    感謝所有幫助傢伙子目錄「responsive_template」,大加讚賞。

    BR 大衛

  • 回答

    2

    我找到XAMPPWAMP這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] 
    

    讓您將htaccess文件出主應用程序文件夾的側

    設置自己的基本網址一些東西一樣

    $config['base_url'] = 'http://localhost/project/'; 
    $config['index_page'] = ''; 
    

    注:您可以將基本URL空白,但是當你提交有時一個形式,你會發現可能無法正常提交。因爲它顯示 ip_adress的網址,而不是localhost

    目錄

    application 
    
    system 
    
    .htaccess 
    
    index.php 
    

    使用CodeIgniter 3個版本,確保你也有類和文件 名字的第一個字母大寫。

    文件名如:的welcome.php

    <?php 
    
    class Welcome extends CI_Controller { 
    
        public function index() { 
    
        } 
    } 
    
    +0

    工作就像一個魅力!非常感謝! :) – user3395711

    0

    你應該試試這個:

    ------------------------------------ config.php ---------------------------- 
    
        $config['base_url'] = ''; 
        $config['index_page'] = ''; 
        $config['uri_protocol'] = 'REQUEST_URI';// if this will not work. comment this line and remove comment from below line 
    // $config['uri_protocol'] = 'AUTO'; 
    
    ---------------------------------- .htaccess ----------------------------- 
    
        RewriteEngine on 
        RewriteCond %{REQUEST_FILENAME} !-f 
        RewriteCond %{REQUEST_FILENAME} !-d 
        RewriteRule .* index.php/$0 [PT,L] 
    

    注: - 確保您的.htaccess文件被放置在根目錄下。在具有index.php文件的response_template目錄中。