CodeIgniter Htaccess And URL Rewrite Issues


Answer :

There are 3 steps to remove index.php.

  1. Make below changes in application/config.php file

    $config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name'; $config['index_page'] = ''; $config['uri_protocol'] = 'AUTO'; 
  2. Make .htaccess file in your root directory using below code

    RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
  3. Enable the rewrite engine (if not already enabled)

    i. First, initiate it with the following command:

    a2enmod rewrite 

    ii. Edit the file /etc/apache2/sites-enabled/000-default

    Change all AllowOverride None to AllowOverride All.

    Note: In latest version you need to change in /etc/apache2/apache2.conf file

    iii. Restart your server with the following command:

    sudo /etc/init.d/apache2 restart 

Your .htaccess is slightly off. Look at mine:

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

Notice "codeigniter" in two places.

after that, in your config:

base_url = "http://localhost/codeigniter" index = "" 

Change codeigniter to "ci" whereever appropriate


<IfModule mod_rewrite.c>    RewriteEngine On    RewriteBase /dmizone_bkp    RewriteCond %{REQUEST_FILENAME} !-f    RewriteCond %{REQUEST_FILENAME} !-d    RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)    RewriteRule ^(.*)$ /dmizone_bkp/index.php?/$1 [L] </IfModule>  

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?