-2

My link show this:

http://localhost/project/index.php

I want this:

http://localhost/project/

Do not display extension

Arifur Rahman
  • 100
  • 2
  • 12
  • the question didnt provide sufficient info when it was posted but this was later edited, will remove the comment, thanks for noticing – Navneet Krishna Nov 11 '17 at 11:35
  • Read more about MVC Pattern – Faridul Khan Nov 11 '17 at 11:36
  • Check in `APPPATH.'config/config.php` file what is set for `$config['url_suffix'] = '';` option. Blank string is default. Making `$config['url_suffix'] = '';` from `$config['url_suffix'] = '.php';` would give you wanted result. But be aware, there's catch: you could break links in all view or controller files if (and I'd believe to) those are set with suffix. – Tpojka Nov 11 '17 at 15:22
  • What this has to do with mvc? @FaridulKhan – Linus Nov 13 '17 at 07:32

4 Answers4

2

You don't understand MVC pattern, there is no direct access to files within URL, everything is redirected to one page.

Full URL: http://localhost/project/home/about

root: http://localhost/project

controller: home

method inside given controller: about

Read more about MVC in Codeigniter's website: https://www.codeigniter.com/user_guide/overview/mvc.html

Or here: https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

Aleksa Arsić
  • 524
  • 1
  • 8
  • 16
1

CodeIgniter provide Routing rules/URI Routing for this.

You can achive this by adding variable to $route array in

/application/config/routes.php file

$old_path = 'home/about'; // no need to add .php to about

$new_path='home/about'; //or about or any other name you want

$route[$new_path] =$old_path;

Now you can visit page by only

http://localhost/project/home/about

For more details :-

https://www.codeigniter.com/user_guide/general/routing.html?highlight=route

Satish
  • 696
  • 1
  • 11
  • 22
0

Codeigniter's mvc works as project_folder/index.php/controller/function.

If you modify this behaviour with htaccess it might collapse the behaviour of the framework.

Learn how it works and get clarified. This link might help you.

-2

Create a file with the name ".htaccess" just ".htaccess" NOT "test.htaccess" or so. Write this code in it ->

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Now you can link your sites like this -> <a href="http://test/abc">Test</a>