}
}
- if strings.HasPrefix(req.URL.Host, "www.reddit.com") {
+ if host == "www.reddit.com" {
req.URL.Host = "old.reddit.com"
http.Redirect(w, req, req.URL.String(), http.StatusMovedPermanently)
return
}
+ if host == "habrastorage.org" &&
+ strings.Contains(req.URL.Path, "/webt/") &&
+ !strings.HasPrefix(req.URL.Path, "/webt/") {
+ req.URL.Path = req.URL.Path[strings.Index(req.URL.Path, "/webt/"):]
+ http.Redirect(w, req, req.URL.String(), http.StatusFound)
+ return
+ }
+
resp, err := transport.RoundTrip(req)
if err != nil {
sinkErr <- fmt.Sprintf("%s\t%s", req.URL.Host, err.Error())
location := resp.Header.Get("Location")
w.Write([]byte(
fmt.Sprintf(
- `<html>
-<head><title>%d %s: %s redirection</title></head>
-<body>Redirection to <a href="%s">%s</a>
-</body></html>`,
+ `<html><head><title>%d %s: %s redirection</title></head>
+<body>Redirection to <a href="%s">%s</a></body></html>`,
resp.StatusCode, http.StatusText(resp.StatusCode),
redirType, location, location,
)))