CodeIgniter removing index.php from url

前端 未结 30 1880
[愿得一人]
[愿得一人] 2020-11-21 11:51

My current urls look like this [mysite]index.php/[rest of the slug].
I want to strip index.php from these urls.

mod_rewrite

30条回答
  •  半阙折子戏
    2020-11-21 12:15

    In CodeIgniter 3.16 in using htaccess to

    remove index.php file

    & also

    redirect HTTP to HTTPS

    Follow are the codes:

    • go to application\config\config.php file

    Make changes

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

    To

    $config['index_page'] = '';
    
    • Now, Open the .htaccess file, and update the codes below
    RewriteEngine on
    RewriteBase /
    
    ## Redirect SSL
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
    
    ## Remove fron url index.php
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond $1 !^/(index\.php|assets/|humans\.txt)
    RewriteRule ^(.*)$ index.php/$1 [L] 
    
    

提交回复
热议问题