Using myDomain.com/subject/ instead of full URL

I’ve got a website which uses a PHP variable to get the current page, URLs look like

www.myDomain.com/index.php?page_name=myPage

But I would like to represent that URL using

www.myDomain.com/myPage/

How do I do this with code? Obviously I could actually build the directory structure, but that would defeat the purpose of using a generalized PHP template. I’m not sure what language support this needs - I’m guessing its a Javascript thing…