G
G
Glory2021-12-02 16:34:34
Laravel
Glory, 2021-12-02 16:34:34

How to avoid 404 error in Laravel if route ends with php?

created a route containing a php file at the end, namely:

//https://sitename.ru/bitrix/admin/1c_exchange.php

Route::get('bitrix/admin/1c_exchange.php', [getFilesController::class,'getDataFrom1C']);
Route::post('bitrix/admin/1c_exchange.php', [getFilesController::class,'getDataFrom1C']);


when accessing this route using methods get, the postserver gives a 404 error.
In laravel, there is nothing in the logs.

What can be wrong? under windows with openserver everything worked without problems. this route worked.

specified in the file cors.php: specified in the file :
'paths' => ['api/*', 'bitrix/*'],

VerifyCsrfToken.php
protected $except = [
        'bot/*',
        'bitrix/*'
    ];


But this was not enough. Does anyone have experience configuring Laravel + Nginx to allow scripting.

I cannot not specify the name of the script, because in 1C this script is called.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maiskiykot, 2021-12-11
@maiskiykot

You are trying to call a non-Laravel file. Hence the scolding. I needed to call test php files in LUMEN here - I did this:

$router->get('tests/{alias}', function(Request $request) {
    ob_start();
    require($request->path());
    return ob_get_clean();
});

Most likely you have the same problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question