Removing index.php in CodeIgniter using .htaccess file

后端 未结 6 2448
悲&欢浪女
悲&欢浪女 2020-12-15 13:32

I\'m currently developing a website using CodeIgniter and I recently stumbled upon a routing & .htaccess problem.

Basically, the structure of my simple website (

6条回答
  •  爱一瞬间的悲伤
    2020-12-15 14:01

    I have use following method, it is working perfectly in UBUNTU...!!

    First of all verify that you have enabled mod_rewrite (you can verify using phpinfo()) in your index.php file.

    IF DISABLED mod_rewrite then RUN: 1. sudo a2enmod rewrite 2. sudo gedit /etc/apache2/sites-available/defaut just replace "AllowOverride None" to "AllowOverride All" in Tag(<'Directory /var/www/'>) 3. Then please run sudo service apache2 restart

    Ok Good... Now in your root directory of Codeigniter -> Find .htaccess file, if not found then press ctrl+h , still not found then create a file .htaccess

    In .htaccess Paste following code :

    
            RewriteEngine On
            RewriteBase /ROOT DIRECTORY NAME/
    
            # Directs all EE web requests through the site index file
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php/$1 [L]
    
    

    Ok finally just replace ROOT DIRECTORY NAME

    DONT FORGOT TO REMOVE index.php from application/config/config.php file Make that line like $config['index_page'] = '';

提交回复
热议问题