Reputation: 514
I am working with the older version of Laravel and I don't which version I am working on as this project was given to me for debugging. I have zero knowledge of Laravel. Doing php artisan --version gave me this as an output in git bash
Following is the code:
<nav class="sidebar sidebar-offcanvas" id="sidebar">
<ul class="nav">
<li class="nav-item nav-profile">
<div class="nav-link">
<div class="user-wrapper">
<div class="text-wrapper">
<p class="profile-name"><?php echo GetUserDetail::get(Session::get('admin_id'),'fullname');?> <span class="status-indicator online"></span></p>
</div>
</div>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="dashboard" style="background-color: #518be6 !important; width:250px; color: #fff !important; border-radius: 0px;">
<i class="fas fa-tachometer-alt menu-icon" style="color: #fff"></i>
<span class="menu-title">ड्याशबोर्ड</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="service">
<i class="fas fa-briefcase menu-icon"></i>
<span class="menu-title">सेवाहरू</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="resource">
<i class="fab fa-osi menu-icon"></i>
<span class="menu-title">संसाधन</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="agenda">
<i class="fab fa-forumbee menu-icon"></i>
<span class="menu-title">परियोजना</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="profile">
<i class="fas fa-people-carry menu-icon"></i>
<span class="menu-title">प्रोफाइल</span>
</a>
</li> <li class="nav-item">
<a class="nav-link" href="notice">
<i class="fas fa-info-circle menu-icon"></i>
<span class="menu-title">सूचना तथा जानकारी</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="add_user">
<i class="fas fa-user-plus menu-icon"></i>
<span class="menu-title">थप प्रयोगकर्ता</span>
</a>
</li>
</ul>
</nav>
I tried keeping /
just before href
like href="/dashboard"
. My expected output is http://demo.com/admin/dashboard
but when I click on the link it goes like this http://demo.com/dashboard
.
I also tried doing href="{{ url('dashboard')}}"
which converts my URL to like this:
http://demo.com/admin/%7B%7B%20url('dashboard')%7D%7D
What should be done to fix this?
Upvotes: 0
Views: 297
Reputation: 1536
Your short fix would be this,
href="/admin/dashboard"
The problem was with the way html use href attribute. When you put '/' (forward slash) at the very beginning it starts from the root directory not from the current directory.
However this is a bad practice. You should study routing method and url generation . For large project your url controller will be much easier.
(I don't know your version of laravel. So I provided the link of the latest version. But you can change it from menu.)
Upvotes: 1