Support the ongoing development of Laravel.io →
Laravel Routing Artisan

I am currently on

http://127.0.0.1:8000/cars/

I have a link that has to route me to

http://127.0.0.1:8000/cars/create

I used this in my code

            <a
                href="cars/create"
            </a>

In my web.php I have following route

Route::get('cars/create',function ()
{
    return view('carsops.create');
});

When I click on link I am redirected to

http://127.0.0.1:8000/cars/cars/create

Instead of

http://127.0.0.1:8000/cars/create

What is the error why I am getting this extra /cars. Can some one help me.

Last updated 3 years ago.

varun6578 liked this thread

1
moderator

You created a relative link that use the current page as starting point.

In your example, you are on: http://domain.tld/cars/

cars/create result in http://domain.tld/cars/cars/create
/cars/create result in http://domain.tld/cars/create
http://domain.tld/cars/create result in http://domain.tld/cars/create

Another option is to use the url helper.

            <a
                href="{{ url('cars/create')}}"
            </a>
Last updated 3 years ago.
0

Hello Varun Sharma,

You Can Use This Also

<a href="{{'cars/create'}}">Link</a>

0

@varun6578 You can simply write like this

<a href="/cars/create" </a>

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.