• 3 Posts
  • 606 Comments
Joined 3 years ago
cake
Cake day: July 28th, 2023

help-circle


  • If it’s a link to an external site, redirecting to local won’t really do anything useful. I still feel like I’m missing something. I’ll give it a last try.

    If I start a local super basic webserver:

    python3 -m http.server 8000 2>&1 | tee -a logfile.txt
    

    so that I’m running a server on localhost, port 8000 creating logfile.txt, I can do something like this on the file:

    sed 's|"http://\([^/]*\)|"http://0.0.0.0:8000//1|'
    

    which should rewrite a url from:

    http://foo.bar/testing/link
    

    to

    http://0.0.0.0:8000/foo.bar/testing/link
    

    Now if you click on that link, it won’t do anything except give you an error, but:

    $ cat logfile.txt
    127.0.0.1 - - [27/Mar/2026 00:12:49] code 404, message File not found
    127.0.0.1 - - [27/Mar/2026 00:12:49] "GET /foo.bar/testing/link HTTP/1.1" 404 -
    

    so you’d now have a log of all attempts which would be easy to clean up.