Override uri_protocol on specific controller in Codeigniter - codeigniter

I need to override the uri_protocol which is in config file for some controllers in CodeIgniter. I need to change it to "PATH_INFO" since i am using Oauth 2.0,the authorization code is returned via query string.
Thanks in Advance!

I got the Query string worked by adding the line to the config file,
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
$config['uri_protocol'] = "PATH_INFO";

Related

How change admin login url in Codeigniter 1?

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';

Default controller (under modules) not loading under HMVC, CodeIgniter, throws 404 err

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

Codeigniter Issue route issue

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

hmvc codeigniter uri routing

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.

Routing issue with 404_override

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.

Resources