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

Intentional Routes to Error Pages #27

Open
ScottHamper opened this issue May 1, 2017 · 1 comment
Open

Intentional Routes to Error Pages #27

ScottHamper opened this issue May 1, 2017 · 1 comment

Comments

@ScottHamper
Copy link

ScottHamper commented May 1, 2017

Hey All,

Are there any built-in routes for purposefully triggering specific error pages? I'd like to tweak the default .htaccess file to rewrite URLs for sensitive files (e.g., dotfiles) so that the 404 page is displayed. Currently, the .htaccess file does a 301 redirect to /error, which leaks information on whether or not a file exists on the filesystem (redirect? it exists. no redirect? it does not exist). In either case, the HTTP response status is 404 (instead of, for example, 403 Forbidden), which is good, but I'd like my 404s to be consistent in not redirecting users away from the URL they originally accessed.

I've found that I can simply rewrite the URL to index.php and it will trigger the Grav 404 page for these files. Is this solution ideal/adequate, or are there possible edge cases that will produce inconsistent results? Is there another solution entirely? Though my use case at the moment is really only concerned with explicitly routing to the 404 page, would it make sense to support routing to any HTTP error status code page?

Regards,
--- Scott

EDIT: After looking into this more, it seems like the current behavior actually differs depending on platform. For example, the .htaccess file does cause a 403 Forbidden to occur, while the web.config file causes a redirect to /error which responds with a 404. Regardless, my end goal is to always return a 404 and never redirect.

@CarlSinclair
Copy link

I just simplified things by making all errors present as 404. The user doesn't need to know (nor care) what's causing the error.

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

No branches or pull requests

2 participants