freak9999 Posted December 11, 2006 Share Posted December 11, 2006 I'm using ForceType and the code below to change the URI address of included files to replace the ?file=filename with /directory/filename (aka 'search friendly URLs')[code]<?phpglobal $REQUEST_URI;global $SCRIPT_NAME;$path = $SCRIPT_NAME;$base_href = dirname($path);$vars = str_replace($path, "", $REQUEST_URI);$array = explode("/",$vars);$num = count($array);for ($i = 0 ; $i < $num ; $i++) { $url_array["arg".$i] = $array[$i];}$page = $url_array["arg1"];$page2 = $url_array["arg2"];?>[/code]Then:[code]<?php $content = "$page/" . $page2 . ".php"; if (!file_exists($content)) { $content = "inc/error.html"; include($content); } else { include($content); }?>[/code]The file to be included is in a folder - directory1It is called test_includeThe file with the above code is called initialfile (The ForceType has been set on this)I'm finding this usually works but if I copy the exact same file (test_include.php) to a different folder - directory2 the file (to be included) cannot be found. I have checked the file exists and tried numerous variations of folder name or file name and cannot work out any pattern to why it sometimes works and sometimes not.Can anyone advise if there are any conditions that stop this from working.How can this be?Many thanks, mat Link to comment https://forums.phpfreaks.com/topic/30233-unreliable-uri-replacement-dirname-str_replace-url_array-explode/ Share on other sites More sharing options...
freak9999 Posted December 11, 2006 Author Share Posted December 11, 2006 amalgamated above Link to comment https://forums.phpfreaks.com/topic/30233-unreliable-uri-replacement-dirname-str_replace-url_array-explode/#findComment-139063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.