how to make sub folder for login page and rest of the pages in codeigniter - codeigniter

I am working in a codeigniter project in wamp server.
My current login page is http://localhost/flowers/login and its working correctly (no issue). The rest of the urls are like this
http://localhost/handycheck/admin/dashboard etc
My issue is i need to change the login url like this
http://localhost/flowers/admin/login
&
http://localhost/flowers/providers/login
Its because I have to maintain login form for multiple users.
How can i make this.
Please help me and thanks in advance who helps me alot..

You can do this by adding custom roue in codeigniter routing configuration as follows go to config/routes and add the following entry in this file
$route['flowers/providers/login'] = 'flowers/login';
$route['flowers/admin/login'] = 'flowers/login';
this will redirect the request to the login in flowers controller and if you need to do custom handling for admins and provider you can get the url segments and do custom handling according to user type
I hope my answer would be useful

Related

Handling multiple views controllers in CodeIgniter 4

I am new to CodeIgniter 4.
I have one controller named Pages and helps to display website pages normally. Then I have another controller named Admin which is suppose to load the admin view with its own header and footer files.
While Pages controller works fine, the Admin controller keeps saying 404-file not found admin.
I think I have a problem with my current Route settings below. Please help.
$routes->setDefaultController('Pages');
$routes->setDefaultMethod('default');
// Route Definitions
$routes->get('/', 'Pages::index');
$routes->get('(:any)', 'Pages::default/$1');
try ajusting your code like this.
$routes->setDefaultController('Pages');
$routes->setDefaultMethod('default');
// Route Definitions
$routes->resource('pages');
$routes->get('/', 'Pages::index');
$routes->get('(:any)', 'Pages::default/$1');

Laravel Nova: The login form is in HTTP instead of HTTPS

Context
I've installed Laravel Nova, executed the migrations and created the Nova user by following the docs https://nova.laravel.com/docs/3.0/installation.html#installing-nova . Now I'm trying to login.
Expected behavior
When I send the login form, I'm redirected to the backoffice panel.
Actual behavior
When I send the login form, I'm redirected to a Chrome page "This page is not secured, are you sure you want to send your form data?" (approximately the English translation of the French displayed error :D ).
Clues
The login form is shown at this URL: "https://.../nova/login".
The login form, however, contains this action: "http://.../nova/login" - NB: so it's not HTTPS, but HTTP.
Question
Where could I set a Laravel and/or Nova config option to tell Nova to use https instead of http in the action of the login form Nova shows?
Since Nova doesn't seem to use any environment/configuration option to be able to choose the good HTTP/HTTPS protocol, I've directly written the following, in app/Providers/AppServiceProvider (NB: I don't really know the drawbacks of this solution so I don't recommend you to do it, even if in my case it worked well to fix this bug):
public function boot()
{
\URL::forceScheme('https');
}

How to load an codeigniter application by using different url

Now I am developing an application by using CodeIgniter framework. In this application, there is a section which name account setup. By using this section we can create multiple accounts. As an example, accounts name are abc, bca or anything. And Suppose my site URL is: www.xyz.com (base_url) Then we need to access the site by the domain name and also domain name with account name like bellow:
www.xyz.com
www.xyz.com/abc/
www.xyz.com/bca/
www.xyz.com/anything/
For More clear, URL pattern will be:
www.xyz.com/dashboard/index
www.xyz.com/abc/dashboard/index
www.xyz.com/bca/dashboard/index
How can we do it? I need your suggestion.
Yes it's Possible through codeigniter Routs.
Go to application\config Open a file which Name is routes.php
you can call the controller functions see in code example
example
$route['new_project'] = "controller/function";
when you hit your website url like this www.xyz.com/new_project it will go to your mention controller and function.
see the documentation of routs CodeIgniter URI Routing
example 2:
$route['account/(.*)'] = "controller/function";
Now we you redirect your url like this
redirect('account/'.$name_var.'');
Now your url look like this.
www.xyz.com/account/name_of_logged_in_user
Also you can use this like this.
$route['(.*)/dashboard/index'] = "controller/function";
And then you can call it like this.
redirect(''.$name_var.'/dashboard/index');
And from this code your output url show something like this.
www.xyz.com/name_of_logged_in_user/dashboard/index
Hope it will help you if any question add comment
There are many way to do it.
1) Domain alias if you want to run same script with different domain.
2) if you want to run same script with sub domain then you can do it from Cpanel
3) If you want to run same script with different folders in same domain then you need to use htaccess

How do I change the index page in a CodeIgniter anchor?

So, I have two different applications in my CodeIgniter installation. One is admin, the other is frontend. I basically just copied the index file, renamed it "admin.php", and changed the application directory to "application/admin". I then changed the application directory in index.php to "application/frontend".
What I would like to do is create a link on the frontend application that takes you to the admin application. The variable config['index_page'] in the frontend application is set to "index.php" and in the admin application it's set to "admin.php".
Is there a way to set the url helper to use "admin.php" instead of "index.php"?
You don't need to do that way.
you should make or use an authentication library and you set different roles for different
users.
you just after login can put the redirection to your admin controller.
and for other users and viewers you can redirect them to any other controllers.
for viewers you can just use something like this:
Code:
if(!$this->m_auth->is_logged_in())
{
$this->viewers();
}
else
{
$this->users();
}
In your users function you just check different roles and redirect according.
I think you are missing some codeigniter concept, and you are trying to do it the normal way, i suggest you to read this article , you will how you can use MY_Controller as same concept of front controller and how you will be able to give every use specific roles
another way is to use a ready made authentication library as #medhi said
I would recommend Tank Authentication or Ion Auth
I

how to get the admin login page by inserting /ci-admin like /wp-admin in wordpress

I am wondering if that is possible to view the admin login page just by typing /CI_ADMIN after the domain name just like we do in wordpress.
http://www.abc.com/wp-admin
and I want to do
http://www.abc.com/ci-admin
for my codeigniter website. is that possible ? the url thing
you can do this with routes just define route in you routes.php file
$route['ci-admin'] = 'ci_admin/login';
for more how to create admin panel please read this article specially third method
CI Admin panel

Resources