8

so the thing is I'm using .htaccess to hide the index.php but I still get the controller name in the url like that: http://example.com/name_controller/about My question is: is it possible to hide the name of the controller, so that only method is shown? hxxp://example.com/name_controller/about

5 Answers 5

17

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Is this required to be done for all the pages, there isn't any automated solution which will apply the rule to all the routes by default?
5

You can add an entry in the /system/application/config/routes.php file:

$route['about'] = "controller_name/about";

Comments

2

$route['default_controller'] = "xxx";

home

$route['home'] = "xxx/home";

function_name/parameter0/parameter1/parameter2

$route['Collection/(:any)'] = "xxx/Collection/$1";

Comments

2

I did it like this: (config/routes.php)

Code: $route['((photos|blogs).+)'] = "$1";

$route['([a-zA-Z0-9_-]+)'] = "user/profile/$1";

it is ok correct solutions for common.

1 Comment

please try to clarify the last phrase, it sounds very unclear
0

You can add below code in the /application/config/routes.php file:

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

$route['(?i)about'] = "Home/about";
$route['(?i)login'] = "Home/Login";
$route['(?i)products'] = "ProductController/ProductList";
$route['(?i)addproduct'] = "ProductController/AddProduct";
$route['(?i)editproduct'] = "ProductController/EditProduct";
$route['(?i)products/(:any)'] = "ProductController/ProductList/$1";//search product list perameters.

100% It work..

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.