You could just get the permalink and strip the home root from it-
$path = substr( get_permalink(), strlen( home_url("https://wordpress.stackexchange.com/") ) );
You could just get the permalink and strip the home root from it-
$path = substr( get_permalink(), strlen( home_url("https://wordpress.stackexchange.com/") ) );