[Bug]: Trailing slash for sites without routing system
Platform
macOS
Operating system version
macOS 15.5
System architecture
Intel (x86)
Herd Version
1.20.3
PHP Version
All versions
Bug description
When a site without a routing system is added in Herd, no trailing slash is appended to the URL. This causes relative links (e.g. for images or stylesheets) to break, as the browser looks one directory level too high.
As a workaround, we add the following to herd.conf:
server {
listen 127.0.0.1:80 default_server;
#listen VALET_LOOPBACK:80; # Valet loopback
root /;
charset utf-8;
client_max_body_size 128M;
# Add trailing slash to paths
rewrite ^([^.]*[^/])$ $1/ permanent;
location ~* /41c270e4-5535-4daa-b23e-c269744c2f45/([A-Z]+:)(.*) {
internal;
alias $1;
try_files $2 $2/;
}
We use Herd in an educational context where students build plain PHP websites without a routing system. We discussed this issue at the Laravel conference in Amsterdam, and your team mentioned it was noted for future improvement.
A possible solution could be to add a toggle in the Sites section of the Herd settings, allowing the trailing slash rewrite to be enabled per site.
We hope this gets addressed—thanks again for building such a helpful tool!
Steps to reproduce
Install Herd add a plain HTML / PHP site to the Herd folder. Link an image relative in the code
Relevant log output
I would also love to see this feature. Within education, we start with simple PHP-only websites before moving to Laravel websites. So having this would help enormously! Thanks in advance!