B, cyanobacteria and nitrifying bacteria belong to autotrophic prokaryotes, and B is correct;
C, cyanobacteria belong to autotrophic prokaryotes, while rhizobia belong to heterotrophic prokaryotes, and c is wrong;
D. Spirogyra and Porphyra are autotrophic eukaryotes, and D is wrong.
Therefore, choose: B.