Why i got other url in active url laravel?

爱⌒轻易说出口 提交于 2021-02-11 14:41:45

问题


I am using Laravel 8 and I am facing issue with URL on local server ubuntu. When I on http://www.ereciept.com/ route then each and everything working fine. If i hit an other route like http://www.ereciept.com/invoices/show and then i cal ajax route http://www.ereciept.com/language/key then the hit url become http://www.ereciept.com/invoices/language/key. I don't know what happening. My we file is

Route::get('language/{key}', [SwitchLanguageController::class, 'switchLanguage'])->name('language');

Route::get('register', [RegisterController::class, 'showRegistrationForm'])->name('register')->middleware(['otpVerify']);
Auth::routes();
Route::group(['middleware' => 'auth'], function (){

Route::get('/404', [\App\Http\Controllers\ErrorController::class, 'notFound'])->name('404');
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');

Route::get('profile/show', [AuthenticationController::class, 'profile'])->name('profile.show');

Route::get('invoices/show', [InvoiceController::class, 'index'])->name('invoice.show');

});

and My ajax function is.

<script>
$('.language').on('click', function (ev){
    ev.preventDefault();
    let key = $(this).data('key');

    $.ajax({
        type : 'get',
        url : 'language/'+key,
        success:function(data){
            window.location.reload(true);
        }
    });

});

and if i send request as http://www.ereciept.com/invoices/show its work fine but if i hit http://www.ereciept.com/invoices then url become http://www.ereciept.com/public/invoices My .htaccess code is

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

How can I solve this issue. Please help

来源:https://stackoverflow.com/questions/65614151/why-i-got-other-url-in-active-url-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!