简体   繁体   中英

How can i use a different url name to access a controller in codeigniter

I have a controller admin in my codeigniter project, i don't want users to directly access it like

'localhost://myproject/admin'

I want it to display a 404 error instead.

i want to use

localhost://myproject/something

to load my controller and i don't want to change my controller name, meanwhile my controller name is Admin. is this possible? if it is what a re the possible ways of going about it

my route :

$route['controller/admin'] = 'controller/something'.

The left value of the route setting is the part that comes from the URL, the right value is the the one it should get rerouted to.

In your case you would need to swap the strings you chose to:

$route['controller/something'] = 'controller/admin'

But as the controller is named admin, you need to use the following rerouting (following /controller/method/parameter ):

$route['something'] = 'admin'

Don't forget to add wildcards .

Here 'sa link to the routing documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM