$id = isset( $_SERVER[ 'REQUEST_URI' ] ) ? basename( $_SERVER[ 'REQUEST_URI' ] ) : false;
// Убрал здесь basename() вокруг $_SERVER[ 'HTTP_USER_AGENT' ] из-за бессмысленности.
$user_agent = isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? $_SERVER[ 'HTTP_USER_AGENT' ] : false;
$url = 'http://сайт.ру';
if ( $id !== false && $user_agent !== false ) {
$post_data = array( 'url' => $url . '/' . $id );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$postResult = curl_exec( $ch );
curl_close( $ch );
echo $postResult;
} else {
header( 'HTTP/1.0 404 Not Found' );
}