Skip to content
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

404 page doesn't appear if the directory the page is in exists #135

Closed
sdomi opened this issue May 7, 2017 · 3 comments
Closed

404 page doesn't appear if the directory the page is in exists #135

sdomi opened this issue May 7, 2017 · 3 comments

Comments

@sdomi
Copy link
Contributor

sdomi commented May 7, 2017

Custom 404 works, but only when you try a page on root that doesn't exist (such as "/asdfasfasf"). Old 404 appears, if you try a page in directory css, js or img(such as "/img/asdfasdfasfd").

@sdomi sdomi changed the title 404 page doesn't appear if the directory is real 404 page doesn't appear if the directory the page is in exists May 7, 2017
@Atvaark
Copy link
Contributor

Atvaark commented May 7, 2017

These handlers match every route with a css/js/img prefix and return the default 404 response. The NotFoundHandler will only be used when no route was found.

http.Handle("/css/", http.StripPrefix("/css/", cssHandler))
http.Handle("/js/", http.StripPrefix("/js/", jsHandler))
http.Handle("/img/", http.StripPrefix("/img/", imgHandler))

If you want to return the custom 404 page you'd have to wrap the handler with a customized one that checks if http.ResponseWriter.WriteHeader(int) got called with http.StatusNotFound.

@SpamNeko
Copy link
Contributor

SpamNeko commented May 9, 2017

https://github.com/ewhal/nyaa/pull/236 Fixed this

@s-varezhkin
Copy link
Contributor

^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants