-1

I have a site that I want to pass directly to the controller method without going through the class in codeigniter.

https://website.com/product_number instead of https://website.com/index/product_number

I want that to go directly to my main controller method.

config/routes.php

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

controllers/Welcome.php

function index($product_number)
{
  //process $product_number output
}

Would this be possible in codiegniter?

tereško
  • 58,060
  • 25
  • 98
  • 150
  • you need to change your `.htaccess` file to remove `index.php` from `url` . – PHP Ninja Jan 15 '20 at 10:13
  • Does this answer your question? [CodeIgniter removing index.php from url](https://stackoverflow.com/questions/19183311/codeigniter-removing-index-php-from-url) – PHP Ninja Jan 15 '20 at 10:13

2 Answers2

0

Open config/routes.php then add this line to it

$route['(.+)'] = 'welcome/index/$1'; I hope this helps your situation.

Kasim Ridwan
  • 194
  • 2
  • 8
0

Open

/application/config/config.php

then find this line

$config['base_url'] = 'https://website.com/index/';

and Replace with

$config['base_url'] = 'https://website.com/';

I hope this Aswer very helpful for you.

Mujahid Bhoraniya
  • 1,518
  • 10
  • 22