CodeIgniter removing index.php from url

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

    Step 1 :

    Add this in htaccess file

    
      RewriteEngine On
      #RewriteBase /
    
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^ index.php [QSA,L]
    
    

    Step 2 :

    Remove index.php in codeigniter config

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

    Step 3 :

    Allow overriding htaccess in Apache Configuration (Command)

    sudo nano /etc/apache2/apache2.conf
    

    and edit the file & change to

    AllowOverride All
    

    for www folder

    Step 4 :

    Enabled apache mod rewrite (Command)

    sudo a2enmod rewrite
    

    Step 5 :

    Restart Apache (Command)

    sudo /etc/init.d/apache2 restart
    

提交回复
热议问题