PHP: Fetching foldername from URL

Reply

Join Date: Dec 2004
Posts: 234
Reputation: cancer10 is an unknown quantity at this point 
Solved Threads: 0
cancer10's Avatar
cancer10 cancer10 is offline Offline
Posting Whiz in Training

PHP: Fetching foldername from URL

 
0
  #1
Mar 16th, 2008
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

  1. <?php
  2. echo $_SERVER['HTTP_HOST'];
  3. ?>



Please help.


Thanx
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 158
Reputation: sDJh is an unknown quantity at this point 
Solved Threads: 13
sDJh sDJh is offline Offline
Junior Poster

Re: PHP: Fetching foldername from URL

 
0
  #2
Mar 18th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum


Views: 707 | Replies: 1
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC