Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

Why i got other url in active url laravel?

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...