0

I would like to remove our welcome contoroller from url how to remove index using codegniter

$route['^(:any)(/:any)?$'] = "welcome/$0";

but my links are

<?php echo site_url('welcome/about'); ?>
<?php echo site_url('welcome/index'); ?>
<?php echo site_url('welcome/contact'); ?>

When click this link the url is same welcome/contact and error page occurred my $route only works localhost/mydomain/index when click any url localhost/mydomain/welcome/contact

Adi Singh
  • 57
  • 9
  • Possible duplicate of [Routes in Codeigniter - Automatically](https://stackoverflow.com/questions/7618633/routes-in-codeigniter-automatically) – Abdulla Nilam Aug 03 '17 at 07:06
  • When you are directing to a index function you don't need to include it `` not `` –  Aug 03 '17 at 07:25

2 Answers2

0

if you ONLY want to remove 'welcome' from the URL,

you could do:

$route['(:any)'] = "welcome/$1"

Others:

You can define a custom route in config/routes.php - for example:

$route['about'] = 'name_controller/about';

Then, http://example.com/about
goes to http://example.com/name_controller/about

See Hiding the controller’s method name in the URL? in the CI forums for more information.

Chandra Kumar
  • 4,127
  • 1
  • 17
  • 25
0

You can add route in config/routes.php

For Ex :

$route['about'] = 'welcome/about';
$route['index'] = 'welcome/index';
$route['contact'] = 'welcome/contact';

You can used Like :

localhost/mydomain/about
localhost/mydomain/index
localhost/mydomain/contact

Please set Your Site URL Like :

<a href="<?= base_url() ?>about">Abouts<a/>
<a href="<?= base_url() ?>index">Index<a/>
<a href="<?= base_url() ?>contact">Contact<a/>
NikuNj Rathod
  • 1,663
  • 1
  • 17
  • 26