I want the following to happen
The url something.com/why-us to go to content controller
The url something.com/nepal to go to location controller
How to manage the above in CI routes
Apply the below coding in routes.php in config folder
$route['why-us'] = "content_controller";
$route['nepal'] = "location_controller";
use your desire controller
Related
Im using codeigniter 1 for a web system I want to change admin login url to my custom login url
current url - *http://siteUrl/admin/login*
Want to change - *http://siteUrl/adlogin*
How can I change this using config/router.php
thanks.
make route in config/routes.php
$route['siteUrl/adlogin']='controllername/methodname';
You can create routes for Your New URL Like :
URL:
application_url/application/config/routes.php
$route['adlogin'] = 'admin/login;
Please try this solution for your problem.
Use That on Route Without parameter Pass
$route['adlogin'] = 'admin/login';
With parameter Use This..
$route['adlogin/(:any)'] = 'admin/login/$1';
Just migrated my CI from localhost to live. Everything works fine on localhost with same settings.
Here're the folder/file structure and contents of routes.php
-application
--controllers
---Home.php
--modules
---specs
----controllers
-----Specs.php
----models
----views
$route['default_controller'] = 'Specs/index';
//$route['default_controller'] = 'Home/index';
$route['404_override'] = 'Errors/show_404';
$route['translate_uri_dashes'] = FALSE;
Both Specs and Home controllers have index method. When I load the home page url with Specs/index as default controller, I get 404 error. But if I change the default controller to Home/index, it loads just fine. Strange. Everything else works just fine on whole site. Can't figure out.
The website is live but I'm not sure if providing url is allowed, so I'm including spaces in it. It's unspecs dott comm. Admin/Mods may please remove if url isn't allowed.
Thanks for reading.
I think you are doing mistake in routing, for HMVC it should be like that -
$route['default_controller'] = '<folder name>/<controller name>/<function name>';
$route['default_controller'] = 'specs/Specs/index';
Please follow this, hope it will work fine.
Try this https://stackoverflow.com/questions/6529026/codeigniter... But better use standart folder for default controller /application/controllers
Fins below the route code.
Route::get('clientlayout.main.index','InvoiceTicketController#show');
Route::get('clientlayout.main.mydomains','InvoiceTicketController#set');
When I run these routes I'm getting the url as
http://localhost:8000/clientlayout.main.index and
http://localhost:8000/clientlayout.main.mydomains.
I want my Url to be changed as follows: http://localhost:8000/index and http://localhost:8000/mydomains.
Suggest me a solution for changing the route to rectify this issue.
Route::get('/index','InvoiceTicketController#show');
Route::get('/mydomains','InvoiceTicketController#set');
for named routes you can use like this way
Route::get('/index','InvoiceTicketController#show')->name('clientlayout.main.index');
for more details follow
https://laravel.com/docs/5.6/routing#named-routes
You should try the route.
Route::get('/clientlayout/main/index','InvoiceTicketController#show');
Route::get('/clientlayout/main/mydomains','InvoiceTicketController#set');
Url is making
http://localhost:8000/clientlayout/main/index
http://localhost:8000/clientlayout/main/mydomains
Or You Should try
Route::get('/index','InvoiceTicketController#show');
Route::get('/mydomains','InvoiceTicketController#set');
Then Url is making
http://localhost:8000/index
http://localhost:8000/mydomains
I have and CI hmvc structure as below:
application
config
config.php
routes.php
...
modules
login
personal
config
config.php
routes.php
controllers
libraries
models
views
HMVC works fine. So, here's my problem: Inside /modules/personal/config/routes.php i have this:
$route['personal/empleados/actualizar.legajo'] = 'personal/empleados/actualizar_legajo/';
$route['personal/empleados/nuevo-cargo'] = 'personal/empleados/nuevo_cargo/';
But it doen't work. The file is loaded but routing doesn't work.
If i cut and copy these two lines and paste them inside: /application/config/routes.php, works.
Can anybody tell me why ? Because i have several modules and i would like to do this inside each modules/module-name/config/config.php
Thanx, in advance.
Have you tried to set the default controller in each module ?
You may also need to add the folder path.
modules/personal/config/routes.php
$route['default_controller'] = 'personal';
// OR //
$route['default_controller'] = 'personal/personal';
Thanx for your answer.
I set my default controller as you tell but it fails anyway.
On the other hand i found a solution (?) as follow on modules/module-name/config/routes.php
$route['personal/empleados/nuevo.cargo'] = 'empleados/nuevo_cargo/';
and... IT WORKS. I don't know why. But it works.
I'm having an issue with 404_override in CI 2.02. Here is my default controller and override:
$route['default_controller'] = "home/index_controller";
$route['404_override'] = "misc/site_map";
This line uncommented gives me this error:
Unable to load your default controller. Please make sure the
controller specified in your Routes.php file is valid.
But commented, I get a 404 error. So something in the override is causing the problem. I just don't know what. I've tried various MY_Router files and they don't help. Anyone have any suggestions about how I can fix this?
I've eliminated my .htaccess file as the problem by deleting it from the server and then trying to access a controller that doesn't exist like this: http://domain.com/index.php/doesnotexist. I still get the error.
For anyone else coming here with this issue, this is/was a bug in CodeIgniter itself to do with 404 pages not being able to be included in subfolders.
Bug Discussion Including Fix on GitHub
You have forgotten to add the default controller that will be used when you first load your website, in your routes.php you need to add this, it is required which is why you're seeing the errors being thrown.
$route['default_controller'] = 'index'; // this will need to be changed to your default controller
$route['404_override'] = 'misc/site_map';
EDIT:
Okay, you must make sure you enter the correct controller name you wish to load as the default, for example you have home.php in your controllers folder, you must enter home as the default. Optionally, you can define segments that are functions in your home.php class file, e.g. home/function_name.