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', [AppHttpControllersErrorController::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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…