I want to map URL in my localhost XAMPP into custom files.
For example:
localhost/index.php
-->d:\xampp\htdocs\index.php
(default)localhost/normal/data.php
-->d:\xampp\htdocs\normal\data.php
(default)localhost/view/userinfo.php
-->d:\xampp\htdocs\view.php?p=userinfo
(custom)localhost/view/welcome.php
-->d:\xampp\htdocs\view.php?p=welcome
(custom)
So, basically, all URL that goes into inside view
path will be mapped to view.php files with the filename.php (minus the .php) as its query parameter. There's actually no physical folder view
, and no physical files userinfo.php and welcome.php inside the folder.
The reason that I need to do this is that so I can pass all the pages that viewing data into an "application frame" that will wrap the page with header, menu, and footer, and I don't need to give header, menu, and footer call in each page. I might have the actual files userinfo.php that I can $include_once, or I might not (I can just generate it from within the view.php), but hey, that's one of the power of this kind of framework, right? And, if someday I need to change this structure, I can change it from just within one file (view.php), not all.
Can I do this in PHP and XAMPP? How? I've noticed that some website seems to used this practice (URL which have no actual files or even path at all), but when I try to read tutorial for it, I got confused.
The accepted answer listed 3 links to learn about URL rewriting. Mostly they're written for Apache in Linux, and mostly they pull all the possible scenario and configuration that I got confused which one I really need with all those long documents and technical jargon. I need just the practical step of my specific problem, and then, I will be able to start from there to explore myself if I have more advanced needs. Please help.