Dear Friends, I am working around a simple cms-like php script to oversee my custom needs. While striving with friendly urls i've got stuch with passing some query string to include files. Options -Indexes Options +FollowSymLinks RewriteEngine on RewriteBase /oz RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/?q=$1 [L,QSA] Code (markup): The above is my htaccess file and I workout all requests in the index.php file and include the requested files. and this is what my index.php contains: <? require_once("fbase.php"); $q = $_GET['q']; $rpage = $q ? $q : "index"; //Retrieved Page $activetable = "oz_".$_GET['ozellik']; // This is a workaround for the DB $requesturi = request_uri(); if ($q) { // Trim the trailing slash if exists $q = trim($q,"/"); // echo $_SERVER['SCRIPT_NAME']; // Set parameters given after the url $params = $requesturi; $sizep = strlen($params); $pos = strpos($params, "?"); if ($pos > 0) { $params = substr($params, $pos+1, $sizep); } //Check if there is such a file in the given path if (file_exists("$q.php")) { setparams($params); include("$q.php"); } // Maybe there is a blockname associated with it. elseif ( /*(loadblocks(8,1) > 0) || */ (loadblocks(2,1) > 0) || (loadblocks(4,1) > 0) /* || (loadblocks(9,1) > 0) */ ) { include("header.php"); include("footer.php"); // This means the requested url is not recognized, lets associate it. } else { // Lets check if we have a directory separator. if (eregi("/",$q)) { $dizinler = explode("/",$q); $ds = (Count($dizinler) - 1) ; $aranan_url = $dizinler[$ds]; unset($dizinler[$ds]); $activetable = "oz_".$dizinler[0]; } else { $aranan_url=$q; $activetable = "oz_general"; } if (is_associated($aranan_url)) { setparams("some=params&comes=here"); include("ozellik.php"); } else { include("header.php"); bTable(); echo "<center>Sorry no page here.<br> Consider typo...</center>"; eTable(); include("footer.php"); } } } else { include("index2.php"); // Default welcome page } function is_associated($url) { if (mysql_num_rows(mysql_query("Select term from girdiler where unique_seo_term='$url'")) > 0) return true; else return false; } function request_uri() { if (isset($_SERVER['REQUEST_URI'])) { $uri = $_SERVER['REQUEST_URI']; } else { if (isset($_SERVER['argv'])) { $uri = $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['argv'][0]; } elseif (isset($_SERVER['QUERY_STRING'])) { $uri = $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['QUERY_STRING']; } else { $uri = $_SERVER['SCRIPT_NAME']; } } return $uri; } function setparams($params) { if (isset($_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] .'?'. $params; } else { if (isset($_SERVER['argv'])) { $_SERVER['argv'] = $_SERVER['SCRIPT_NAME'] .'?'. $params; } elseif (isset($_SERVER['QUERY_STRING'])) { $_SERVER['QUERY_STRING'] = $_SERVER['SCRIPT_NAME'] .'?'. $params; } } } ?> PHP: Everything works fine except, when I try to include a file after if (is_associated($aranan_url)) { Code (markup): if block the included file fails to read the query string. Any help or other workaround would be greatly appreciated. Thanks in advance.
included files can get value from url or post data, because the code is "imported" to the main file. both $_GET or $_POST will work, of course if they are set.
Yeah It gets the variables, the problem was that my required mainfile.php sets variables with the key names of _GET and _POST variables, Why it did not work on me was I have been trying to pass the newly generated parameters with setting the request_uri and query_string. Now I found out to workaround. 1. setting variables rather then rebuilding the query_string 2. re assigning the keys in the _GET to new variables. Thanks for your contributions.