html - Hyperlink multi-level sub-directories through index.php? structure -
i'm trying create hyperlink structure can access multi-level sub folders. now, can access hyperlinks one-level (php) directory, such index.php?content=about
(whereas 'about' about.php).
what want create filing system larger website multi-level sub-directories following example, index.php?blog/category/process/
. don't know if there symbol replaces html symbol / (slash directory) php directories. tried different ways of accessing files inside multi-level sub-directories, such putting ? (question mark). hypothetically experimental. if use slash, such in form 'blog/category/process/filename.php
', 404 not found error.
there following php script inside function.php, gets content url, if there no content, sets default , if there content, sanitizes data against hacking:
function loadcontent($where, $default='') { $content = filter_input(input_get, $where, filter_sanitize_string); $default = filter_var($default, filter_sanitize_string); $content = (empty($content)) ? $default : $content; if ($content) { $html = include 'content/'.$content.'.php'; return $html; } } function loadincludes($where, $default='includes/') { $includes = filter_input(input_get, $where, filter_sanitize_string); $default = filter_var($default, filter_sanitize_string); if($includes) { $html = include 'includes/'.$includes.'.php'; return $html; } }
the link document inside 'blog/category/process/filename.php' shows (where '404 error' before, header , css files not work. not been picked up.
please note:
website structure is
header (one header picked index.php?)
content (multiple content=filename.php)
footer
index.php looks this:
<?php require ('includes/function.php'); require ('includes/init.php'); /* init.php picks header */ ?> <div class="clearboth"></div> <!-- ******** homepage ********** --> <?php loadcontent('content', 'home'); ?> <div class="clearboth"></div> <!-- ******** footer ********** --> <?php include ('content/footer.php'); ?>
i found solution on structure of multi-level sub-directories through index.php? picks css, follows:
<a href="index.php?content=blog/category/process/filename"> (leave out extension .php followed after 'filename')
thank help!
<?php /* folders structure $_server['document_root'] = c:/server/www/music; // yes windows :) file = folders.php c:/server/www/music c:/server/www/music/files/ c:/server/www/music/files/folder1/ c:/server/www/music/files/folder1/folder2/myfile.jpeg */ $root = $_server['document_root']; $requesturi = $_server['request_uri']; $startfolder = '/files/'; preg_match('/\?/', $requesturi) ? list($requesturi, $filetofind) = explode('?', $_server['request_uri']) : exit('bad request'); $file = $root.$startfolder.$filetofind; if(file_exists($file)){ //your code } else { header("http/1.0 404 not found"); } // usage = http://music.com/folders.php?/folder1/folder2/myfile.jpeg ?>
read questions had asked before. hope you
.htaccess : redirect http requests 1 file whitout 404 resp. code
note may play http headers header($_server["server_protocol"]." 404 not found");
or header($_server["server_protocol"]." 200 ok");
in case file exists or not
active imagination...
Comments
Post a Comment