42 Pa. C.S. § 6503 : Consolidated Statutes — JUDICIARY AND JUDICIAL PROCEDURE — ACTIONS, PROCEEDINGS AND OTHER MATTERS GENERALLY — HABEAS CORPUS — Right to apply for writ

(a) General ruleExcept as provided in subsection (b), an application for habeas corpus to inquire into the cause of detention may be brought by or on behalf of any person restrained of his liberty within this Commonwealth under any pretense whatsoever.
(b) ExceptionWhere a person is restrained by virtue of sentence after conviction for a criminal offense, the writ of habeas corpus shall not be available if a remedy may be had by post-conviction hearing proceedings authorized by law.

42 Pa.C.S. § 6503

1976, July 9, P.L. 586, No. 142, § 2, effective 6/27/1978.
SECTIONS