Giter Site home page Giter Site logo

Comments (7)

taylorotwell avatar taylorotwell commented on May 5, 2024 4

Just don't use trailing slashes.

from framework.

softlabs-2 avatar softlabs-2 commented on May 5, 2024

I have been having the same issue when you create Resource Controller using Route::resource('test', 'TestController') and creating the controller using ''php artisan controller:make TestController".

Then when you browse to /test or /test/create or /test/1 it works fine but when you add a trailing slash like /test/ or test/create/ it throws NotFoundHttpException.

Just wondering if this will remain how it is or if it is a bug to be fixed?

from framework.

pauljohnston avatar pauljohnston commented on May 5, 2024

I'm also having the same issue, anything with a trailing slash doesn't route and just shows an error.

from framework.

franzliedke avatar franzliedke commented on May 5, 2024

Duplicate content has to be taken into account when handling this. The proper solution, if anything, would be to redirect to one of the two variants (but only if the other one of them is defined).

from framework.

BenJenkinson avatar BenJenkinson commented on May 5, 2024

I don't think that's really a solution. Users may use trailing slashes. We may construct our URLs specifically forgoing them, but a user may still type a URL that includes one. We should be able to cope.

Traditionally, the segments of a URL are emulating the folder structure. Where although /example/docs/routing may be a page on the documentation, /example/docs/ is considered the main index of the documentation and it would be reasonable to expect a page to exist there. The URL structure /example/docs would indicate that docs is a page of the example section, when it is actually an index in its own right.

I have found some web services with APIs that insist upon one format over the other, or that use / to indicate whether the RESTful resource returns a single item or a list of items; but I cannot find any public-facing websites that follow the current behavior and do not either serve identical content, or redirect to the preferred URL-format (whether that be with, or without a /).

Even http://laravel.com currently functions in this way, laravel.com/docs/ produces the documentation as well as laravel.com/docs does.

It is of course preferable that a single page does not exist at two different addresses, but at the very least it should redirect from one to the other.

from framework.

tomicakorac avatar tomicakorac commented on May 5, 2024

It's possible to fix this using .htaccess, by rewriting or redirecting to url either with or without trailing slash. It's also possible to enable both variants. Although I agree this should be changed so that na url works with or without /$.

from framework.

 avatar commented on May 5, 2024

Just came across this issue too. Any URL with a trailing slash now returns a NotFoundHttpException since updating to the latest version of L4 this morning.

I'm also of the opinion that Laravel should redirect to one or the other.

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.