By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

help pls..how to clear a url query string

P: n/a
hi guys,

my url is in this form: http://www.mysite.com?user=zen

what to do to remove the query string (..?user=zen) and make my url to
this form: http://www.mysite.com

tnx

Apr 24 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"shotokan99" <so**********@yahoo.comwrote in message
news:11**********************@t39g2000prd.googlegr oups.com...
hi guys,

my url is in this form: http://www.mysite.com?user=zen

what to do to remove the query string (..?user=zen) and make my url to
this form: http://www.mysite.com

$url = 'http://www.mysite.com?user=zen';
list($shorturl) = explode('?', $url);
echo $shorturl;

--
Ra*********@gmail.com

"Good tea. Nice house." -- Worf
Apr 24 '07 #2

P: n/a
Rami Elomaa napisał(a):
"shotokan99" <so**********@yahoo.comwrote in message
news:11**********************@t39g2000prd.googlegr oups.com...
>hi guys,

my url is in this form: http://www.mysite.com?user=zen

what to do to remove the query string (..?user=zen) and make my url to
this form: http://www.mysite.com


$url = 'http://www.mysite.com?user=zen';
list($shorturl) = explode('?', $url);
echo $shorturl;
there is a shorter way:
echo strtok($url,'?');

;)

--
Wiktor Walc
http://phpfreelancer.net
Apr 24 '07 #3

P: n/a
On Apr 24, 5:08 am, shotokan99 <soft_devj...@yahoo.comwrote:
hi guys,

my url is in this form: http://www.mysite.com?user=zen

what to do to remove the query string (..?user=zen) and make my url to
this form:http://www.mysite.com

tnx
$parts = parse_url('http://www.mysite.com?user=zen');
$url = $parts['scheme'] . '://' . $parts['host'];

Apr 24 '07 #4

P: n/a
tnx...it did the trick ;-)

Apr 25 '07 #5

P: n/a
C.
On 24 Apr, 10:22, "Rami Elomaa" <rami.elo...@gmail.comwrote:
"shotokan99" <soft_devj...@yahoo.comwrote in message

news:11**********************@t39g2000prd.googlegr oups.com...
hi guys,
my url is in this form: http://www.mysite.com?user=zen
what to do to remove the query string (..?user=zen) and make my url to
this form:http://www.mysite.com

$url = 'http://www.mysite.com?user=zen';
list($shorturl) = explode('?', $url);
echo $shorturl;

--
Rami.Elo...@gmail.com

"Good tea. Nice house." -- Worf

It's probably safer to use parse_url() see http://www.php.net/function.parse-url

C.

Apr 25 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.