Varun Kumar
Varun Kumar

Reputation: 478

Code Igniter URL routing confusion

I have a slight issue. I have configured my default controller as :

c$route['default_controller'] = 'news';

so when I point my browser to http://localhost/mysite all the news get loaded as instructed by the news controller. Now on this page, I have given links to "read article" to read the full article. For this I have to point my browser to http://localhost/index.php/news/view/news-slug. I want to remove index.php from the url. I had already tried re-routing using wildcard without any success. Can you tell me how to do that?

Upvotes: 0

Views: 224

Answers (2)

Ninja
Ninja

Reputation: 5152

You need to define your .htaccess file for this. Check this wiki: http://codeigniter.com/wiki/mod_rewrite

Upvotes: 0

MacMac
MacMac

Reputation: 35351

There is a documentation on removing the index.php from the URL if you are using Apache with it's mod_rewrite:

Using the following rewrite code:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Also, there are many similar questions to yours, have a look at these questions from the search:

Upvotes: 4

Related Questions