laravel-localization icon indicating copy to clipboard operation
laravel-localization copied to clipboard

Disable Redirects Only for 404 Requests

Open ahmetsmc opened this issue 1 year ago • 3 comments

I couldn't find it in config file, can we disable redirects for some requests or 404 requests?

ahmetsmc avatar May 29 '23 14:05 ahmetsmc

configration file is config/laravellocalization.php but for creation should use this: php artisan vendor:publish --provider="Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider" so, the config file created automaticly.

if you are use Laravel 10.X i gues not compitable. for solution, i am using like this: <a href="{{Laravellocalization::localizeUrl('/anythink')}}">Link</a>. so your URLs will change to: ``http://127.0.0.1:8000/en/anythink`

sorry for bad English, good code!

alihan0 avatar May 31 '23 04:05 alihan0

configration file is config/laravellocalization.php but for creation should use this: php artisan vendor:publish --provider="Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider" so, the config file created automaticly.

if you are use Laravel 10.X i gues not compitable. for solution, i am using like this: <a href="{{Laravellocalization::localizeUrl('/anythink')}}">Link</a>. so your URLs will change to: ``http://127.0.0.1:8000/en/anythink`

sorry for bad English, good code!

thank you for your suggestion, I already published my config file but I didn't see the setting I needed here

i am using middleware on routes

Route::group(
        [
            'prefix' => \Mcamara\LaravelLocalization\Facades\LaravelLocalization::setLocale(),
            'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'localeViewPath']
        ], function () {

        Route::get('/cities', function(){
        // my routes
        });
)};

this middleware redirect all requests correctly but i need disable redirects only 404 requests. do you have any idea?

ahmetsmc avatar May 31 '23 23:05 ahmetsmc

yapılandırma dosyası config/laravellocalization.phpancak oluşturma için bunu kullanmalıdır: php artisan vendor:publish --provider="Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider"yani yapılandırma dosyası otomatik olarak oluşturulur. Eğer kullanıyorsanız, Laravel 10.Xsanırım uyumlu değil. çözüm için şöyle kullanıyorum: <a href="{{Laravellocalization::localizeUrl('/anythink')}}">Link</a>. böylece URL'leriniz şu şekilde değişir: `` http://127.0.0.1:8000/en/anythink` Kötü İngilizce için üzgünüm, iyi kod!

önerin için teşekkür ederim, zaten yapılandırma dosyamı yayınladım ama ihtiyacım olan ayarı burada görmedim

rotalarda ara yazılım kullanıyorum

Route::group(
        [
            'prefix' => \Mcamara\LaravelLocalization\Facades\LaravelLocalization::setLocale(),
            'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'localeViewPath']
        ], function () {

        Route::get('/cities', function(){
        // my routes
        });
)};

bu ara yazılım tüm istekleri doğru bir şekilde yönlendirir, ancak yalnızca 404 isteği yönlendirmeleri devre dışı bırakmam gerekir. herhangi bir fikrin var mı?

I couldn't see any settings to disable 404 requests. Maybe others know. If I come across it, I'll post it here.

alihan0 avatar Jun 01 '23 04:06 alihan0