Does this happen for all sites in Local, or just one in particular?
All sites.
Replication
Create a brand new Wordpress site in Local WP using localhost Router Mode. Open the site (http://localhost:whateverport). Now try adding just “wp-admin” to the end of the URL (instead of “wp-admin/” with a trailing slash).
System Details
Which version of Local is being used?
6.1.4+5521
What Operating System (OS) and OS version is being used?
Windows 10 Pro and Windows 11 Pro
Sorry, I mistakenly typed “Router Mode” when I meant “localhost Router Mode”. I edited my original question.
Both of those links you shared are basically the inverse of the problem I’m experiencing—they’re using Site Domains Router Mode instead of localhost Router Mode, and they are getting a port added to the URL when it shouldn’t be.
In my case, I’m using localhost Router Mode, and everything works great except the one wp-admin URL without a trailing slash, where the port gets removed from the URL when it shouldn’t be.
The siteurl in the Wordpress database is http://localhost:10001.
Visiting that last URL redirects me to http://localhost/wp-admin with no port (port 10001 disappears), which results in a 404 Not Found. I can’t reproduce this on any other server with the identical site code and database (except for a changed siteurl in the db, obviously).
I don’t have any plugins installed. This is a default Wordpress install, with the default template, with absolutely no content or plugins added. I’ve been happily using Local WP for over a year, but this problem occurs with every single site I’ve ever worked on with localhost Router Mode.
I was just able to replicate this. I’m not 100% sure where this is failing, but I think this might be a bug with our site’s nginx config not accounting for the port when redirecting.
I’ll keep investigating things and reply here when I have more info!
@ben.turner Cool, thanks for the reply! No rush, it’s just been one of those minor thorns in my side, mainly because I was worried that I might have something configured incorrectly with Local WP. I’m just happy to hear that you’re seeing the same problem and I’m not crazy. Thanks again.
I think I’ve zeroed in on what’s going on, and will create a bug for the Local devs to work on.
The actual fix will need a little more attention since we’ll have to consider all of the edge cases, but if you’re just using the localhost router mode, you should be able to update the nginx config for the site within the wordpress-single.conf.hbs file by adding :$server_port to the rewrite: