Thank you all for your responses. I am disappointed about the publishers directing what one writes (in a sense), but I appreciate the help.
They don't direct what you write. They direct what you can publish using their intellectual property.
If you want to write whatever you want based on someone else's intellectual property, then that is fanfic.
If you want to publish writing based on someone else's intellectual property, you have to play by their rules.
And the mods here have decided they don't want to go anywhere near the minefield which is the legality of sharing fanfic.
(Which, for the record, and as a fanfic writer, I think is entirely reasonable. There are plenty of fanfic sites we can use.)