创建包含single.php模板标签的重定向页面

I want to make each visited single page is first redirected to template.php page that has original targeted post permalink like AdFly shorten url service.

As for now it works using PHP header() Function. But I couldn`t figure out how to get original source page permalink to be included in template.php

<?php
 header("HTTP/1.1 301 Moved Permanently");
 header("Location: http://www.yournewwebsite.com/template.php");
?>

You could pass the link as a parameter in the location.

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://example.com/template.php?website=" . $_SERVER['REQUEST_URI']);

And in your template.php, simply do $_GET['website'] to retrieve the url passed in the param.