-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should /page/ work just like /page ? #1189
Comments
/page/
work just like /page
/page/
work just like /page
For me this makes sense. Personally, I think having this workflow would make sense.
In other words |
kind of related #619 |
I mostly agree with your reasoning @krhome83 but your statement in point 2 (/page would 404) is not logically consistent
|
Let me know if I'm off base, but otherwise, I think I'd like to add a "smart default" for this scenario (since we also have a custom server override for https://zeit.co), provided that we can turn it off in config ( |
Also, I wonder if this should warn or be an error, since it's kind of not obvious
|
IMHO in that case we should probably error unless you turn off |
I think the best option is to do a |
|
Yep I guess we don't. |
Agree with the 301 redirect. Nice and simple. https://moz.com/learn/seo/redirection Need to maintain that link juice! |
Many people use trailing slash and many dont, however its better to only keep one version of it as per SEO otherwise it will create serious issues as per google. We maintain a trailing slash and I am not sure how I can do it in next js. Any ideas? |
@harshmaur you can create a custom server to handle urls with a trailing slash or you can create |
@sergiodxa Thanks a lot, I was thinking of using server.js to create custom routes for all of my pages instead of using the default router. But I am not sure how that would work on the client side. I need to check. |
@harshmaur check the custom server example specially how to use next/link |
I believe I'm currently running into something like this right now. Using a I believe this is the relevant line in @rauchg would that be the target of your proposed |
SEO-wise 301 redirect is definitely preferred, but should trailing slash in the end be stripped or instead enforced is a question. Note, that besides already mentioned differences above, those paths will work differently with relative urls:
That's because for browsers, no matter what you think and how servers resolves resources, any url with trailing slash is a directory, while without one — a document. Thus, resolution for relative resources will be different. This means that by enforcing certain behavior (trailing slash or lack of one) you effectively removing a way to treat relative urls in different ways. This shouldn't be a real issue, since, as far as I remember, in react-router relative paths are not even supported. But still worth mentioning. Besides, unfortunately, SEO-wise 301 redirect is quite recommended thing for ending slashes. Or, otherwise, at least, canonical urls have to be specified. |
I have been looking at this issue too. One thing worth to mention is that when exporting a page as an html endpoint such as the following causes an extra backslash: {
exportPathMap: () => ({
"/about.html": { page: "/about" }
})
} This makes simple things like an anchor not to work properly since
is not the same as
|
@arunoda @sergiodxa would you guys consider a PR for avoiding the extra backslash in _rewriteUrlForNextExport if the path ends with .html? |
I have the same issue. I'm applying "with-apollo-and-redux" official example. https://github.com/zeit/next.js/tree/master/examples/with-apollo-and-redux I created a pages/test. If i browse localhost:3000/test all it's okey. But if i browse localhost:3000/test/
But the page loads (With all the messages in the console) |
Maybe a temp fix. server.js
package.json
Now this works good except for an error in the first render.
|
@hmontes But this won't be a fix for static exports. |
I would love an internal fix for this that works with next-routes. |
Fixed in next 5 / canary |
url with a trailing slash results in a 404 error using |
@timneutkens Should this be reopened? |
One other similar issue is support for multiple forward slashes, as it's easy for users to miss two of them. Example being: https://github.com/zeit/next.js////////////issues/1189 |
Please see #3876 (comment), where I've shared a minimal example where trailing slashes don't seem to be working. |
For reference: |
Isn't that just for static / next export though? |
I filed a new issue with minimal reproducible repository in #5214 |
What is the status on this issue? It's been open for quite some time. I've just noticed that |
Using v7.02, I have a What's the workaround? |
For what it's worth, I've implemented a force-trailing-slash util at next-i18next to circumvent this issue. In the meantime I would suggest people implement their own middlewares. |
@timneutkens Hi, should this issue be re-opened? It still does not work with current version |
This comment has been minimized.
This comment has been minimized.
ping @timneutkens it seems many people are upvoting to reopen. Any plan to re-open it? |
@rap2hpoutre What is the status of this issue? |
@dryleaf Still no answer. Maybe we should open a new issue. |
@rap2hpoutre it is already opened #5214 |
Seams fixed. The page is accessible with or without trailing slash. Both returning HTTP 200. I am using Next.js v9.3.0 |
I am using Next.js v9.3.0 and not works |
@javiercno see #5214 |
Can we reopen this? @timneutkens is there a hope this could be fixed any time soon? |
@untitledlt see #5214 |
I am using Next.js v9.3.0 and not works.can we reopen this bug? |
@iamstarkov i saw your issue. There's even my comment 3 days ago. |
As said this is already open in #5214 Going to lock this issue as there's no actionable comments here. |
I am using Google Search Console to inspect my website. When adding a website it automatically adds a "/" to the end of the url, therefore
www.website.com/page
becomeswww.website.com/page/
In the case of next page called 'page' this would not work. There are 2 workarounds
Regarding 2 this is what i have done
I wonder wether it makese sense to fix this in next.js itself making it more generic.
The text was updated successfully, but these errors were encountered: