Welcome Guest, Not a member yet? Register   Sign In
Routes Not Working On Live Host ?!!!!!
#1

hello guys i have problem with  Route on real host .every thing work well on localhost but on live host my routes didnt work here my code ? help ci4 funs 






PHP Code:
<?php

namespace Config;

// Create a new instance of our RouteCollection class.
$routes Services::routes();

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH 'Config/Routes.php')) {
    require SYSTEMPATH 'Config/Routes.php';
}

/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers\V1');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);




/*
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/''Home::index');

$routes->group('api', function ($routes) {

    $routes->resource('home');

    
    $routes
->group('auth', function ($routes) {
 
        $routes->post('login''Auth::login');
        $routes->get('logout''Auth::logout');
        $routes->post('register''Auth::register');
        $routes->post('forgot''Auth::forgot');
        $routes->post('reset-password-email''Auth::resetPasswordViaEmail');
        $routes->post('reset-password-sms''Auth::resetPasswordViaSms');
        $routes->get('activate-account-email''Auth::activateAccountViaEmail');
        $routes->get('send-activate-email''Auth::sendActivateCodeViaEmail');
        $routes->post('activate-account-sms''Auth::activateAccountViaSms');
        $routes->post('send-activate-sms''Auth::sendActivateCodeViaSms');
        $routes->post('forgot''Auth::forgot');
    });


    $routes->resource('profile');
    $routes->resource('chatContact');
    $routes->resource('chatRoom');
    $routes->resource('chatRoomMedia');
    $routes->resource('chatPrivate');
    $routes->resource('chatPrivateMedia');
    $routes->resource('dashboard');

    $routes->resource('user');
    $routes->resource('group');
    $routes->resource('setting');
    $routes->resource('visitor');
    $routes->resource('contact');
    $routes->resource('contactMedia');
    $routes->resource('newsCategory');
    $routes->resource('newsSubCategory');
    $routes->resource('newsPost');
    $routes->resource('newsComment');
    $routes->resource('newsMedia');
    $routes->resource('viewOption');
    $routes->resource('viewMedia');
    $routes->resource('advertisement');
    $routes->resource('advertisementMedia');


/*
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need it to be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (file_exists(APPPATH 'Config/' ENVIRONMENT '/Routes.php')) {
    require APPPATH 'Config/' ENVIRONMENT '/Routes.php';

Enlightenment  Is  Freedom
Reply
#2

Maybe not the cause of your problems, but you should probably disable AutoRoute:
PHP Code:
$routes->setAutoRoute(false); 

Is your file structure the same on local and live host? (public directory...?)
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(This post was last modified: 04-18-2021, 12:43 AM by paliz.)

(04-17-2021, 04:23 PM)includebeer Wrote: Maybe not the cause of your problems, but you should probably disable AutoRoute:
PHP Code:
$routes->setAutoRoute(false); 

Is your file structure the same on local and live host? (public directory...?)
(04-17-2021, 04:23 PM)includebeer Wrote: Maybe not the cause of your problems, but you should probably disable AutoRoute:
PHP Code:
$routes->setAutoRoute(false); 

Is your file structure the same on local and live host? (public directory...?)

I didnt change structure 
I try acesss like that 
Www.exmple.com/public/api/auth/login

Login method is POST request is not working but
Logout method is GET request is working

When setautorute to false still i got error too either
Enlightenment  Is  Freedom
Reply
#4

You're not suppose to have the public folder visible like that. That probably means that all the other folders that are supposed to be outside the document root are not.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

(04-18-2021, 05:47 AM)includebeer Wrote: You're not suppose to have the public folder visible like that. That probably means that all the other folders that are supposed to be outside the document root are not.
Look dude  i have two apps frontend angular 11 which  index. Html(root to path www/index. Html) backend ci4 index. Php (root to path www/public/index. Php)
See backend and fronend are seprate it its full stack app  

On local host i access shell cmd 
Can run php spark serve then init  https://localhoat:8080 but live host i dont acess shell cmd 
I got this path www.exmple.com/public/

Then  can call restfull controllers okey
Enlightenment  Is  Freedom
Reply
#6

If CI is only used as backend, you should probably set a subdomain like api.example.com and have your backend (CI) and frontend (Angular) separated with their own domain. The public folder is your document root, it should not be inside the document root with all other files. And don't tell me "look dude" like I'm stupid. You didn't even mention you had 2 separated apps for the front and back.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#7

(04-18-2021, 06:57 AM)includebeer Wrote: If CI is only used as backend, you should probably set a subdomain like api.example.com and have your backend (CI) and frontend (Angular) separated with their own domain. The public folder is your document root, it should not be inside the document root with all other files. And don't tell me "look dude" like I'm stupid. You didn't even mention you had 2 separated apps for the front and back.
 Oky my friend i didnot mean  anthing about using dude in post sorry  about it 

angular its not in 
Document root(public folder)  it s in upper  folder there is no conflict between two index .

ci4 version 4.0.4 dose have problem since i use 4.1.1 i got error on live host
Enlightenment  Is  Freedom
Reply
#8

(04-18-2021, 06:57 AM)includebeer Wrote: If CI is only used as backend, you should probably set a subdomain like api.example.com and have your backend (CI) and frontend (Angular) separated with their own domain. The public folder is your document root, it should not be inside the document root with all other files. And don't tell me "look dude" like I'm stupid. You didn't even mention you had 2 separated apps for the front and back.

you ware rright  man it needs subdomain  api.example.com 
vi4 upload in subdomain   then
 
upload  angular app exmple.com   

now every thing okay 
Enlightenment  Is  Freedom
Reply
#9

Cool, thanks for letting us know it’s now working!  Cool
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB