CodeIgniter removing index.php from url

前端 未结 30 1444
[愿得一人]
[愿得一人] 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
      Removing index.php from url of codeigniter   
    
    Three steps are require to remove index.php from url in Codeigniter.
    
    1)Create .htacess file in parallel to application holder and just copy past the following code:
    
    RewriteEngine On
    RewriteBase /CodeIgniter/
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    
    2) Change $config['index_page'] to blank in config.php in application folder as below:
    
    $config['index_page'] = '';
    
    3) Enable “rewrite_module” of apache.
    
    0 讨论(0)
  • 2020-11-21 12:15

    Follow these step your problem will be solved

    1- Download .htaccess file from here https://www.dropbox.com/s/tupcu1ctkb8pmmd/.htaccess?dl=0

    2- Change the CodeIgnitor directory name on Line #5. like my directory name is abc (add your name)

    3- Save .htaccess file on main directory (abc) of your codeignitor folder

    4- Change uri_protocol from AUTO to PATH_INFO in Config.php file

    Note: First of all you have to enable mod_rewrite from httpd.conf of apachi by removing the comments

    0 讨论(0)
  • 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] 
    
    
    0 讨论(0)
  • 2020-11-21 12:20

    try this one.It may help you as its working for me.

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]
    

    put the code in your root htaccess file.and make sure that you have

    $config['index_page'] = '';
    

    in your config file.

    Please let me know if you face any problem.

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

    I think your all setting is good but you doing to misplace your htaccess file go and add your htaccess to your project file

    project_folder->htaccess

    and add this code to your htaccess

    RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    
    0 讨论(0)
  • 2020-11-21 12:21
    1. make .htaccess file and put this code

       RewriteEngine on
       RewriteCond $1 !^(index\.php|resources|robots\.txt)
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
      
    2. change

      $config['index_page'] = ''; 
      

    remove index.php present in config.php file

    1. rewrite on from your server.
    0 讨论(0)
提交回复
热议问题