^^^^
Yeah - you just want to switch to "your religion" 1 turn before completion of the AP. Then switch back ASAP to buddhism/hindu/judaism whatever after the 5 turn minimum wait. You need to get votes from 1 or 2 allies to win - so they should be at friendly. That's hard to do if you are in a different religion. If you build in the same religion as your religious block of friends, then they will also be eligible in the vote for victory, since that's their state religion. Then they will vote for themselves, not you which isn't good. If the AP is built in a religion that isn't anyone state relgion (only yours for the 5 turns while finishing the AP) then only you are eligible on the vote, since you built the AP and are automatically eligible.
I've only won once with the AP - it was in 1330 AD, a few hundred years earlier than i've ever won before. It was on my 2nd try - i was just trying to see how it works. First try i was 5 votes short in the 1300's, then one of the "bad guys" spread it to all his cities so i started over - wouldn't have been able to win unless i fought some war, which i wasn't ready to do with only a few cities, no army, only experimenting with this AP nonsense.
2nd try was really easy. It was on emperor, i only built 5 cities. Founded Philosophy but wasn't the first to theology. Still managed to build the AP. I was in buddhism, sharing with 2 AI's who i had at pleased/friendly. 1 turn before AP was done i switched to philosophy, finished the AP, then switched back to buddhism 5 turns later as soon as i could. Then i just spread it to all the cities of my 2 allies, then 1 city each of the other 4 AI's.
Building stonehenge and/or the oracle helps - just save a great prophet for bulbing theology. If you don't get the wonders and a prophet, you can also just use a great scientist to bulb philosophy early (what i did) and manually tech theology. Just make sure you can get the AP built before an AI gets it. Also make sure you spread philosophy/christianity (whichever you want to build the AP in) to the city building the AP since you need the state religion in that city. Other than that quick switch to "your" religion for the completion of the AP, just stay in whatever early religion your allies are in.
There are other ways to do it, especially later through conquering - but for a 1200's-1300's victory this way is pretty simple. Just make sure to found a religion, and get the AP built. If you have 2 AI's friendly, and 4 you need to spread it to to open up the victory, spread it to the most religious AI last, since he might spread it further. Since you can only build 3 missionaries at a time, you can't give it to all of them on the same turn. Best thing to do is use 1 to spread it to an AI that already has a religion everywhere, and has a really crappy tundra/island city. Then spread to the remaining 3 more or less simultaneously. That limits the chance they will spread it further before the vote for victory comes up.
Also, don't be afraid to run favorite civics of your allies even if they really aren't the civics you want to be in. If everything works out there is no late game to prepare for - so after teching theology, your tech rate/economy don't matter at all really. Just need enough production to build missionaries and possibly some units for defense if you get attacked. With the 2 nearest AI's friendly with you you'll be pretty safe though. If you do get a DOW you can probably bribe them into the war to help you out.
It was fun to try once, but i doubt i'll do it again soon. Doesn't feel like a "real game". Also, if it doesn't work out as planned there's a good chance you haven't set yourself up in a good position to win any other way.