Andrew
Andrew

Reputation: 846

Change the url in codeigniter

My url like

http://localhost/message/Welcome/index

But i like to show

hhttp://localhost/message/index

remove the controller name

My routes

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

And try this one

$route['message/send'] = "message/welcome/send";

My htaccess

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

Please help me to remove the controller in the middle of url . Thanks in advance!!!!

Upvotes: 0

Views: 64

Answers (1)

Joe
Joe

Reputation: 4907

You can do that simply using your .htaccess file. Add the following rule:

RewriteEngine On
RewriteRule ^(.*)/Welcome /$1 [R=301,L]

That will remove /welcome from your URL using a 301 redirection. Leaving you with: http://localhost/message/index

Make sure you clear your cache before testing this.

Upvotes: 1

Related Questions