Jump to content

Recommended Posts

I am drawing a blank on the PHP code that pulls the end of a URL (after the final slash)...

 

So, in:

 

http://www.thesite.com/subfolder1/sitepage.php?pageID=1234

 

I would want to get:

 

sitepage.php?pageID=1234

 

I know that $_SERVER['QUERY_STRING'] would get me everything after the "?", but I need a little before that too.

 

I tried searching the PHP manual, but obviously my search terms weren't pulling up what I needed.  Thanks!!!

 

 

Link to comment
https://forums.phpfreaks.com/topic/68851-solved-quick-easy-code-question/
Share on other sites

Put this code on that page:

 

echo '<pre>';
print_r($_SERVER);
echo '</pre>';

 

That will make a list of $_SEVER variables and what they would print out if you used them. Just search the list for the URL you are looking for, then it will tell you what variable to use.

The answer is probably REQUEST_URI.

 

Yes, that is it - but not as it is.  Can you help me with some modification, please?  Here's what I need...

 

[REQUEST_URI] would get me something with a long prefix that always ends with "/admin/" before what I am actually trying to capture.

 

I need everything after the /admin/.  Is there any kind of PHP code that could be written to pull out everything after the string of text "/admin/" within the $_SERVER [REQUEST_URI] variable???

 

Thanks!

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.