I built a mobile version of a wordpress site and added some PHP code in the wordpress index.php file to detect mobile users and HTTP-redirects them to m.website.com (which is not a wordpress installation. This PHP standalone mobile site scrapes the wp site for posts and displays them). All works well, and every request to the full site goes to m.website.com instead.
The only problem is that my team leader wants me to redirect website.com/2011/04/13/post-title to m.website.com/2011/04/13/post-title for mobile users. And to do this, my redirection script only needs to know the permalink of the page that index.php is trying to route to. The mobile site's index.php will handle the permalink once it receives it.
N.B. Currently, if you visit m.website.com/2011/04/13/post-title it displays properly. I only need to know how to trap the permalink from inside wordpress and feed it to my mobile redirection code.
Thanks to Tom J Nowell's comment below, I am ready to move the redirection script to whatever file it is at which Wordpress figures out the permalink, and not index.php any longer. So that once the permalink is known, a redirection to
m.website.com/router.php?path=2011/04/13/post-title can be done, which becomes
m.website.com/2011/04/13/post-title via htaccess. Thanks