CodeIgniter removing index.php from url

前端 未结 30 1397
[愿得一人]
[愿得一人] 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:21

    you can go to application\config\config.php file and remove index.php

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

    Change to

    
     $config['index_page'] = '';
    
    
    0 讨论(0)
  • 2020-11-21 12:21

    Note the difference with the added "?" character after ".php", especially when dealing with CodeIgniter:

    RewriteRule ^(.*)$ index.php/$1 [L]

    vs.

    RewriteRule ^(.*)$ index.php?/$1 [L]

    It depends on several other things.. if doesn't work, try the other option!

    0 讨论(0)
  • 2020-11-21 12:22

    on your htaccess use this,

    RewriteEngine On
    RewriteBase /root_folder_name/
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    Hope this helps.

    0 讨论(0)
  • 2020-11-21 12:22

    1.Create a new file .htaccess on root directory.

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

    2. Go to your config.php file and change from $config['index_page'] = 'index.php' to $config['index_page'] = ''

    0 讨论(0)
  • 2020-11-21 12:22

    Solved it with 2 steps.

    1. Update 2 parameters in the config file application/config/config.php
    $config['index_page'] = '';
    $config['uri_protocol'] = 'REQUEST_URI';
    
    1. Update the file .htaccess in the root folder
    <IfModule mod_rewrite.c>
        RewriteEngine On
          RewriteBase /
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    
    0 讨论(0)
  • 2020-11-21 12:22

    you can go to config\config.php file and remove index.php value from this variable

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

    create .htaccess file and paste this code in it.

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

    good chance

    0 讨论(0)
提交回复
热议问题