diff --git a/src/main.rs b/src/main.rs index 50b0fa8..0479e6e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,10 +87,16 @@ impl Context { let relative_path = if relative_path.is_empty() { String::new() } else { - percent_decode_str(&relative_path[1..]) - .decode_utf8_lossy() - .replace('_', " ") + let path = percent_decode_str(&relative_path[1..]).decode_utf8_lossy(); + if path.contains('_') { + let path = path.replace('_', " "); + let _ = write!(stream, "HTTP/1.1 308 Permanent Redirect\r\n"); + let _ = write!(stream, "Location: /{path}\r\n\r\n"); + return; + } + path.to_string() }; + let (pk_file, pki_file, start_level) = if !relative_path.is_empty() { path.push(&relative_path); let (pk_extension, pki_extension) = if let Some(extension) = path.extension() {