Turning off the Nether

1.21.8 and earlier: stop the server, set allow-nether=false in server.properties, save, and start it again.

1.21.9 and newer, including 26.x: portal entry is controlled by a game rule. With the server running, run gamerule allow_entering_nether_using_portals false in the console. It works straight away; use true to turn it back on. On 1.21.9 and 1.21.10 the rule has an older name, so use gamerule and console completion to find it. See the official change notes.

Turning off the End

Vanilla Minecraft has no simple setting for this, but plugin servers do.

What happens to players already in a disabled dimension? Move players to the Overworld first. Blocking portal entry does not delete a dimension or guarantee that players already inside it are teleported out.

Want to reset a dimension rather than turn it off? Delete only that dimension's folder (see "How do I reset or delete my world without losing my settings?").

Want to open it later, like an "End opening event"? On Paper you can use a plugin to block End portals until a set time, instead of changing server files on the day.