lundi 18 janvier 2021

Strange problem: in Laravel 5 project in some cases in the url 'index.php' is showing

My client have website build on Laravel 5. It's working fine. My job was to add some features. And it was working fine. But lately strange thing is showing. Sometimes, but not often in the url 'index.php' is showing. Then the website is showing but it's rendering wrong, only html without css and JS. I noticed that when it is showing and I will log into CMS and then logout everything is going back to normal. It's very strange to me and I don't really know why. For example, normal url is look like this: jjk-law.pl/blog, but sometimes it's like this: jjk-law.pl/index.php/blog. I will add my routes code:

Route::get('/administrator', 'SessionsController@index')->name('panel');

Route::get('/administrator/login', 'SessionsController@loginForm')->name('login');

Route::post('/administrator/login', 'SessionsController@login');

Route::get('/administrator/logout', 'SessionsController@logout');

if(env('CMS_INSTALLED') == false) {
    Route::get('/install-cms', 'SiteController@installForm')->name('install');

    Route::post('/install-cms', 'SiteController@installCMS');

    Route::post('/save-env', 'SiteController@saveEnv');
}

Route::get('/', 'SiteController@home')->name('homepage');

Route::get('/index.php', 'SiteController@home');

Route::post('/s', 'SiteController@search');

if(env('CMS_INSTALLED')) {
    $primary_lang_option = Option::where('name', 'primary_lang')->first();

    foreach (Language::where('active', 1)->get() as $lang) {
        App::setLocale($lang->short_name);

        if($primary_lang_option->value != $lang->short_name) {
            Route::get('/'.$lang->short_name.'/'.__('site.register_page'), 'SiteController@registerForm')->name('member_register_'.$lang->short_name);
        } else {
            Route::get('/'.__('site.register_page'), 'SiteController@registerForm')->name('member_register_'.$lang->short_name);
        }
    }

    Route::post('/register', 'SiteController@register');

    foreach (Language::where('active', 1)->get() as $lang) {
        App::setLocale($lang->short_name);

        if($primary_lang_option->value != $lang->short_name) {
            Route::get('/'.$lang->short_name.'/'.__('site.login_page'), 'SiteController@loginForm')->name('member_login_'.$lang->short_name);
        } else {
            Route::get('/'.__('site.login_page'), 'SiteController@loginForm')->name('member_login_'.$lang->short_name);
        }
    }

    Route::post('/login', 'SiteController@login');

    Route::get('/logout', 'SiteController@logout');

    Route::get('/password/reset', 'Auth\ForgotPasswordController@memberResetPasswordForm');

    Route::get('/password/reset/{token}', 'Auth\ResetPasswordController@showMemberResetForm')->name('member.password.reset');

    Route::post('/password/reset/{token}', 'Auth\ResetPasswordController@setNewPassword')->name('member.password.new');
}

Route::post('/send_mail', 'MailerController@send')->name('send_mail');
Route::get('/wiadomosc-wyslana', 'MailerController@success')->name('form-success');

Route::get('/{path}', 'SiteController@showByUrl')->where('path', '.+');

I think that this problem is somehow connected to CMS, have relation with login and logout to CMS, but exactly how I don't know don't know. Anyone have the same problem? Any advice how to fix it? Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire