Skip to content

Caddyserver middleware to rewrite absolute links to relative ones on the fly

License

Notifications You must be signed in to change notification settings

bgrace/rewrite_absolute_links

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rewrite_absolute_links

Caddyserver middleware to rewrite absolute links to relative ones on the fly

Directive usage:

rewrite_absolute_links foo.example.com
rewrite_absolute_links bar.example.com
rewrite_absolute_links baz.example.com

OR

rewrite_absolute_links foo.example.com bar.example.com baz.example.com

OR

rewrite_absolute_links foo.example.com bar.example.com
rewrite_absolute_links baz.example.com

Caddy will parse any responses with the Content-Type "text/html" as HTML, and rewrite any anchor tags with hrefs whose URL contains one of the configured domains so that it is a relative link.

Expected behavior:

<a href="http://foo.example.com/hello.html"> **becomes**

<a href="/hello.html">

The HTML5 parser will rewrite non-conforming HTML. It can't be helped, mate.

About

Caddyserver middleware to rewrite absolute links to relative ones on the fly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages