Codeigniter URL rewrite to remove index.php

前端 未结 1 586
滥情空心
滥情空心 2021-01-21 12:06

First of all, i have tried the suggestion specified in here:

  • CodeIgniter removing index.php not working
  • codeignitor: Remove index.php not working
相关标签:
1条回答
  • 2021-01-21 12:30

    OK, You mentioned lot of Stack links which related to your question.

    Change this settings

    $config['base_url'] = '';
    $config['index_page'] = '';
    $config['uri_protocol'] = 'AUTO';
    

    and add this in .htaccess

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L] 
    </IfModule>
    

    Note: Some time in localhost index.php will not removed.

    and to include your css/js/images

    CSS:<link rel="stylesheet" href="<?php echo base_url()?>assets/styles/material-design-icons.css" type="text/css" />
    JS : <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/in/easing.js"></script>
    Img: <img src="<?php echo base_url()?>assets/image/logo.jpg" alt=""/>

    So file structure would be

    - application
    - assets
      - style
         - material-design-icons.css
         - font.css
         - app.css
      - js
         - easing.js
      - image
         - logo.jpg
    - index.php
    - .htaccess(Post in my code)
    

    EDIT 01

    In config/routes.php

    $route['default_controller'] = "";//give default controller name
    $route['404_override'] = '';
    
    0 讨论(0)
提交回复
热议问题