0
votes

Ive been struggling to get a .htaccess file working on codeigniter, im having that issue when you load any other page aside index that, every time you click on a link in my nav bar it tacks on an index.php/, so after the first click on a link, you end up with things like http://www.website.com/index.php/index.php/page

When I open an image from site http://website.com/new/index.php/website.com/new/img/gallery/fw1.jpg

My link same as index.php/About">Aboutour team

My config file $config['base_url'] = 'website.com/new/';

How can I solve this problem?

1
What's in your .htaccess file? - RobL
I dont have any .htaccess file now but it didn't work with RewriteEngine on RewriteCond $1 !^(index\.php|assets|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] - maskapsiz
how are you writing your your nav links? You should probably be doing something like site_url('page'); to get the correct URI. Have a look at ellislab.com/codeigniter/user-guide/helpers/url_helper.html - swatkins

1 Answers

0
votes

I use the following .htaccess file, which has always worked for me with CodeIgniter:

<IfModule mod_rewrite.c>
     RewriteEngine on

     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d

     RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

You should also check your application/config/config.php file to make sure it has the following lines (a blank base_url setting means CodeIgniter will auto-generate it):

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

You might also want to check you're generating the links themselves correctly. You can use site_url() for every link to ensure maximum portability. e.g.

<a href='<?=site_url('about')?>>About</a>