943,733 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 868
  • PHP RSS
Mar 16th, 2008
0

PHP: Fetching foldername from URL

Expand Post »
Hi,

I came up with this problem last night.

I have a URL http://www.mysite.com

How do I fetch the folder name that was supplied in the URL.

For example:


http://www.mysite.com/xyz
or
http://mysite.com/myfolder
or
http://www.mysite.com/xxx


Please note that I can either use www or http://www or just http:// in my domain name but I need to fetch the folder name that was supplied in the URL.

PS:

I tried the following code, but it didnt revealed the foldername supplied

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. echo $_SERVER['HTTP_HOST'];
  3. ?>



Please help.


Thanx
Reputation Points: 58
Solved Threads: 1
Posting Whiz in Training
cancer10 is offline Offline
234 posts
since Dec 2004
Mar 18th, 2008
0

Re: PHP: Fetching foldername from URL

maybe you look for: $HTTP_SERVER_VARS["REQUEST_URI"]

you get something like "/home/user123/htdocs/myfolder/"

than you can work the folder out with explode
Last edited by sDJh; Mar 18th, 2008 at 8:16 am.
Reputation Points: 56
Solved Threads: 29
Posting Whiz in Training
sDJh is offline Offline
255 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: row to colum
Next Thread in PHP Forum Timeline: About Popup Window





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC