Issues in removing index.php in CodeIgniter 3

前端 未结 10 1460
灰色年华
灰色年华 2021-01-13 06:53

I want to access my URL\'s without index.php in CodeIgniter. Here is my Blog controller

class Blog extends CI_Controller {

    pub         


        
10条回答
  •  灰色年华
    2021-01-13 07:43

    How to removed index.php from url has been asked so many times, It is the same as what is for codeigniter 2 and 3.

    For Xampp With Codeigniter Windows

    Find application/config/config.php

    Replace This

    $config['base_url'] = "";

    With This

    $config['base_url'] = "your-project-url";

    Replace This

    $config['index_page'] = "index.php"

    With This

    $config['index_page'] = ""

    In main directory create file called .htaccess

    I use code below works fine for me in xampp in windows. More htacces here

    Options +FollowSymLinks
    Options -Indexes
    
    
        Order deny,allow
        Deny from all
    
    
    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]
    

    Note: make sure your controllers are like example Welcome.php instead of welcome.php also you might need to create new routes in your route.php if remove index.php

提交回复
热议问题