Mr.Shawn Posted November 6, 2008 Share Posted November 6, 2008 $page = explode("/", $_SERVER['REQUEST_URI']); The above code is to detect uri variables. I always used $page[1] to see what was the first parameters that was parsed in the browser url. Now, the problem is whether you placed your scripts in root directory or in a folder. If I place my scripts and all files in the root directory it would be like this. The debuuged $page values. Array ( [0] => [1] => ) If I placed my scripts and all files in one folder then it would be like this Array ( [0] => [1] => somefolder [2] => ) I can no longer use $page[1] as the first parameters. Any ideas how I can solve this problem? I want it to be dynamically Quote Link to comment https://forums.phpfreaks.com/topic/131608-solved-url-rewrite-relating-to-_serverrequest_uri-problem/ Share on other sites More sharing options...
Mr.Shawn Posted November 6, 2008 Author Share Posted November 6, 2008 If you guys don't understand what I wrote, can leave a message. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/131608-solved-url-rewrite-relating-to-_serverrequest_uri-problem/#findComment-683634 Share on other sites More sharing options...
kenrbnsn Posted November 6, 2008 Share Posted November 6, 2008 Can you give a better example of what you are trying to accomplish. Ken Quote Link to comment https://forums.phpfreaks.com/topic/131608-solved-url-rewrite-relating-to-_serverrequest_uri-problem/#findComment-683656 Share on other sites More sharing options...
Mr.Shawn Posted November 7, 2008 Author Share Posted November 7, 2008 Okay this is the case. Normally if I does url rewrite on my software where my software will be located in the root folder, it works all fine. I normally use $page = explode("/", $_SERVER['REQUEST_URI']); to return to a variable and then check $page[1]. In this example, www.example.com/somepages/ where the "somepages" refer to $page[1]. But now if I placed my software in a folder, the $page[1] appears to be the folder name and now I have problems retrieving the rewrited url. www.example.com/folder/somepages/ How can I solve this problem? Quote Link to comment https://forums.phpfreaks.com/topic/131608-solved-url-rewrite-relating-to-_serverrequest_uri-problem/#findComment-684240 Share on other sites More sharing options...
kenrbnsn Posted November 7, 2008 Share Posted November 7, 2008 You really should look at the functions parse_url(), pathinfo(), and basename(). Example: <?php $uri = 'http://www.example.com/folder/somepages/'; $pu = parse_url($uri); $path = pathinfo($pu['path']); print_r($pu); print_r($path); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/131608-solved-url-rewrite-relating-to-_serverrequest_uri-problem/#findComment-684318 Share on other sites More sharing options...
Mr.Shawn Posted November 7, 2008 Author Share Posted November 7, 2008 Okay. It's fixed thanks. Quote Link to comment https://forums.phpfreaks.com/topic/131608-solved-url-rewrite-relating-to-_serverrequest_uri-problem/#findComment-684392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.