#How to correctly manage routing in case: -come back to main ('/') and then to the specific view.
16 messages · Page 1 of 1 (latest)
sure ,let me explain
<?php
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::get('/v/index', [\App\Http\Controllers\menu_controller::class, 'index_window']);
Route::get('/v/contact/index', [\App\Http\Controllers\menu_controller::class, 'contact_window']);
Route::get('/services/index', [\App\Http\Controllers\menu_controller::class, 'services_window']);
if i go to one link ,and thant click again it just says page not found,because it adds again to link /v/index ,ex: /v/index/v/index
That has nothing to do with your routes, but more with the anchor links in your view.
You could name your routes, and then use the route helper to properly link. For example:
Route::get('/v/index', [\App\Http\Controllers\menu_controller::class, 'index_window'])->name('window.index');
or if i go to services link for example , and go then to contact it will give link /services_window/contact/index
<a href="{{ route('window.index') }}">Some link</a>
ok !
Your hrefs are just relative right now. Using named routes is best practice.
i see
Relative vs absolute URLs, you're using links like v/index, which the browser just appends to the current URL. You'd want to use absolute paths, like /v/index
yep ,because in my div i have this : <div id="menu"><a href="/services/index">services </a></div>
it works just perfect gentelmans !