Jump to content

[SOLVED] Create a page location using $_SERVER['REQUEST_URI']


matbourne

Recommended Posts

I created a test page to try and create a page location depending on the current page using $_SERVER['REQUEST_URI'].

 

This works on a seperate test page and the code below gives me the desired result.

 

Desired result: ./path/foldername/currentpage.php

 

However, when using the same code in my live website the result is as below:

 

Undesired result: ./path/foldername/

 

Can anyone help me with this please as i am pulling out hair now!  :facewall: All help greatly appreciated

 

Forgive the vagueness of the code, i don't want to give too much away...

 

// Set $currentPage as current page
$currentPage = $_SERVER['REQUEST_URI'];

// Remove / from $currentPage
$currentPage = $str_replace("/", "", $currentPage);

$pageLocation = $path . "foldername" . $currentPage;

 

Link to comment
Share on other sites

Thanks for the quick reply...

 

I'm sure I already checked that,  but just tried it again.

 

It works on my included pages but not on my main index.php page that contains all the site structure and includes...

 

:shrug:

 

I need this to work on my main index.php page and other main pages...

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.