I have a website on a shared server with many users (i.e. example.com/~myusername/
is my home directory, as is still common with many universities) and I am developing the website on a local machine, publishing to the server when I am done with my changes.
The big annoyance is absolute (domain-relative) URLs. URLs that point to /~myusername/path/to/file
break on local machine, while just /path/to/file
works locally and breaks on the server. I need absolute URLs because my site has a navigation bar that persists across many file depths.
One solution is to place my entire local copy in an otherwise empty parent directory, then always use /~myusername/path/to/file
. But I would prefer a solution that allows me to write /path/to/file
, because it is more semantically accurate and I may eventually want to migrate my website to a new server where the full path should be mywebsite.com/path/to/file
. Does such a solution exist?