-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Automatically redirect http://host/folder to http://host/folder/ #1907
Conversation
This will then automatically look for the /index.html file.
I wonder if #1848 will also be fixed with this? |
if (path.back() == '/') { path += "index.html"; } | ||
|
||
if (detail::is_dir(path)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it should also have the opposite part
if (path.back() == '/') { path += "index.html"; } | |
if (detail::is_dir(path)) { | |
if (path.back() == '/') { | |
path.pop_back(); | |
if (detail::is_file(path)) { | |
sub_path.pop_back(); | |
res.set_redirect(sub_path); | |
return true; | |
} | |
path += "/index.html"; } | |
} else if (detail::is_dir(path)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example.com does that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulharris could you please provide at least one unit test case in |
@paulharris I added some test cases and adjust your code to return 301 instead of 302. Thanks for your contribution! |
My apologies for the late reply, it was circling back to this but I'm very happy that you liked it and cleaned it up. |
This will then automatically look for the /index.html file.
This fixes #1389