Jump to content

[SOLVED] url rewrite relating to $_SERVER['REQUEST_URI'] problem


Mr.Shawn

Recommended Posts

$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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.