Say hello to my greater friend: you can do this with just greater create demiplane and symbol of locking.
Unfortunately, it takes more than 50k gp to do, but it's more or less exactly what you asked for.
Create Demiplane, Greater:
This spell functions as create demiplane... when cast within your demiplane, you may add to your demiplane (or remove from it) one of the following features...
**Portal**: Your demiplane gains a permanent gate to one location on another plane, which can only be used for planar travel. This location must be very familiar to you. This gate is always open and usable from both sides, but you can secure it using normal means **(such as by building a door around it).**
The Portal Protocol: demiplanes + symbols
- Greater create demiplane, creating your lynchpin "hallway" demiplane.
- GCD again, picking Portal to make a gate to Location A.
- GCD again for a gate to Location B.
- Permanency on the demiplane. (22,250gp)
- Build any kind of magical and physical defenses (doors? hello?) around the permanent gates you like
- Symbol of locking on both ends to check for the key (400gp)
- Permanency on both symbols (2x 20,000gp)
Cost: 62,650gp + whatever it costs to cast other warding spells, build arches, hire guards, etc.
To connect an additional portal to this dimension:
- Cast GCD again
- Symbol the exterior (200gp)
- Permanency new symbol (20,000gp)
- Construct arches, cast alarm, etc., to taste (variable)
Total cost: 20,200gp per new exit
Now we set the locks to only open for the keys.
First you'll have to make your keys, be they a particular old boot, or a potted plant, or an epic artifact. Once you have them, proceed to the next step: Symbol of LOCKING!
The triggering is based on symbol of death:
You can also set special triggering limitations of your own. These can be as simple or elaborate as you desire. Special conditions for triggering a symbol of death can be based on a creature’s name, identity, or alignment, but otherwise must be based on observable actions or qualities...
So all we need to do, now, is to cast some symbols on each gate, set to trigger when "a creature lacking the key enters range, after more than a minute has passed since the keybearer entered range" **.
Symbol of locking replenishes itself when triggered!
This spell functions as symbol of death, except that you use it to seal a single container, doorway, or portal of no more than 30 square feet per level in size.
An object sealed in such a manner cannot be opened by any means save for breaking the door or object in question. The object can not be passed through by incorporeal creatures in any direction.
Symbol of locking can be made permanent with a permanency spell by a caster of 14th level or higher for the cost of 10,000 gp. A symbol of locking that triggers becomes inactive for 10 minutes, but then reappears, closing the container or portal it is scribed upon and sealing it again.
You'd have to be nuts not to use this!
All symbols trigger equally; some symbols trigger more equally than others
You can add more symbols too; so long as the spells we use are based on the death symbol, the same trigger specifics apply. Some selections:
- symbol of death: Die. 150 HP cap, Fort negates
- symbol of insanity: Go insane permanently. Will negates
- symbol of weakness: 3d6 STR damage. No save.
- symbol of striking: shadow creature makes a bunch of AoOs with the weapon you choose (Will save for half; SR negates)
- DO NOT use symbol of sealing, because it doesn't regenerate when triggered!
The fortifications shouldn't stop there
Despite all this, bear in mind that unless you also build gigantic stone doors, cast hallow, use gates and wards, or any other combination of physical/magical deterrents, then the symbols are the only thing standing in the way of other creatures wandering in. I strongly encourage you to get offensive with your defense!
** Obviously, you can change this condition and work it out with your DM what the effect will be. With the condition I specified, or something like it, a party of 5 could go through the portals without fear, so long as the keybearer went through first. If you set the trigger to simply check for the presence or absence of a keybearer, then the other members are going to trigger the symbol as soon as the keybearer enters the portal and leaves the rest of them behind - or, maybe your DM is less cruel than that, and holds that interplanar portals measure distance like normal distance.