Codeigniter 2 Pretty URLs

To change Codigniters default setting for urls which current shows http://www.domain.com/index.php to pretty urls like http://www.domain.co.nz/page/contact you need to do two things.

Firstly in the application/config/config.php on line 33 change

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

to

$config['index_page'] = '';

 

And in the same directory as your main index.php file add a new file .htaccess and add this code

RewriteEngine On
RewriteCond $1 !^(index.php|images|captcha|css|js|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

 

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.