Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-22-2006, 07:35 PM   PM User | #1
curb
New Coder

 
Join Date: May 2006
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
curb is an unknown quantity at this point
$_SERVER['SCRIPT_NAME'] but only the folder

$domain = $_SERVER['HTTP_HOST'];
$path = $_SERVER['SCRIPT_NAME'];
$url = "http://" . $domain . $path;
echo "$url";

I'm trying to call the url without the current filename.
ex: http://localhost/folder/index.php

But I want it to just show the url without the index.php like this:
ex: http://localhost/folder/
curb is offline   Reply With Quote
Old 08-22-2006, 08:39 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
You can use pathinfo($_SERVER['SCRIPT_URI']); and/or parse_url($_SERVER['SCRIPT_URI']); to dump all the file info to an array and then pick and choose the elements you want.
Fumigator is offline   Reply With Quote
Old 08-22-2006, 08:41 PM   PM User | #3
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
how about something like this:

$domain = $_SERVER['HTTP_HOST'];
$path = $_SERVER['SCRIPT_NAME'];
$basename = basename($_SERVER['SCRIPT_NAME']);
$url = "http://" . $domain . $path;
$newurl = str_replace($basename, "", $url);
echo "$newurl";
mlseim is offline   Reply With Quote
Old 08-23-2006, 08:32 PM   PM User | #4
curb
New Coder

 
Join Date: May 2006
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
curb is an unknown quantity at this point
thanks mlseim, it works.
curb is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:55 PM.


Advertisement
Log in to turn off these ads.